<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
  <meta name="theme-color" content="#222">
  <meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/safari-pinned-tab.svg" color="#222">
  <link rel="stylesheet" href="/css/main.css">
  <link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>
  <script id="hexo-configurations">
    var NexT = window.NexT ||
    {};
    var CONFIG = {
      "hostname": "cuiqingcai.com",
      "root": "/",
      "scheme": "Pisces",
      "version": "7.8.0",
      "exturl": false,
      "sidebar":
      {
        "position": "right",
        "width": 360,
        "display": "post",
        "padding": 18,
        "offset": 12,
        "onmobile": false,
        "widgets": [
          {
            "type": "image",
            "name": "阿布云",
            "enable": false,
            "url": "https://www.abuyun.com/http-proxy/introduce.html",
            "src": "https://qiniu.cuiqingcai.com/88au8.jpg",
            "width": "100%"
      },
          {
            "type": "image",
            "name": "天验",
            "enable": true,
            "url": "https://tutorial.lengyue.video/?coupon=12ef4b1a-a3db-11ea-bb37-0242ac130002_cqx_850",
            "src": "https://qiniu.cuiqingcai.com/bco2a.png",
            "width": "100%"
      },
          {
            "type": "image",
            "name": "华为云",
            "enable": false,
            "url": "https://activity.huaweicloud.com/2020_618_promotion/index.html?bpName=5f9f98a29e2c40b780c1793086f29fe2&bindType=1&salesID=wangyubei",
            "src": "https://qiniu.cuiqingcai.com/y42ik.jpg",
            "width": "100%"
      },
          {
            "type": "image",
            "name": "张小鸡",
            "enable": false,
            "url": "http://www.zxiaoji.com/",
            "src": "https://qiniu.cuiqingcai.com/fm72f.png",
            "width": "100%"
      },
          {
            "type": "image",
            "name": "Luminati",
            "src": "https://qiniu.cuiqingcai.com/ikkq9.jpg",
            "url": "https://luminati-china.io/?affiliate=ref_5fbbaaa9647883f5c6f77095",
            "width": "100%",
            "enable": false
      },
          {
            "type": "image",
            "name": "IPIDEA",
            "url": "http://www.ipidea.net/?utm-source=cqc&utm-keyword=?cqc",
            "src": "https://qiniu.cuiqingcai.com/0ywun.png",
            "width": "100%",
            "enable": true
      },
          {
            "type": "tags",
            "name": "标签云",
            "enable": true
      },
          {
            "type": "categories",
            "name": "分类",
            "enable": true
      },
          {
            "type": "friends",
            "name": "友情链接",
            "enable": true
      },
          {
            "type": "hot",
            "name": "猜你喜欢",
            "enable": true
      }]
      },
      "copycode":
      {
        "enable": true,
        "show_result": true,
        "style": "mac"
      },
      "back2top":
      {
        "enable": true,
        "sidebar": false,
        "scrollpercent": true
      },
      "bookmark":
      {
        "enable": false,
        "color": "#222",
        "save": "auto"
      },
      "fancybox": false,
      "mediumzoom": false,
      "lazyload": false,
      "pangu": true,
      "comments":
      {
        "style": "tabs",
        "active": "gitalk",
        "storage": true,
        "lazyload": false,
        "nav": null,
        "activeClass": "gitalk"
      },
      "algolia":
      {
        "hits":
        {
          "per_page": 10
        },
        "labels":
        {
          "input_placeholder": "Search for Posts",
          "hits_empty": "We didn't find any results for the search: ${query}",
          "hits_stats": "${hits} results found in ${time} ms"
        }
      },
      "localsearch":
      {
        "enable": true,
        "trigger": "auto",
        "top_n_per_article": 10,
        "unescape": false,
        "preload": false
      },
      "motion":
      {
        "enable": false,
        "async": false,
        "transition":
        {
          "post_block": "bounceDownIn",
          "post_header": "slideDownIn",
          "post_body": "slideDownIn",
          "coll_header": "slideLeftIn",
          "sidebar": "slideUpIn"
        }
      },
      "path": "search.xml"
    };

  </script>
  <meta name="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
  <meta property="og:type" content="website">
  <meta property="og:title" content="静觅">
  <meta property="og:url" content="https://cuiqingcai.com/page/3/index.html">
  <meta property="og:site_name" content="静觅">
  <meta property="og:description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
  <meta property="og:locale" content="zh_CN">
  <meta property="article:author" content="崔庆才">
  <meta property="article:tag" content="崔庆才">
  <meta property="article:tag" content="静觅">
  <meta property="article:tag" content="PHP">
  <meta property="article:tag" content="Java">
  <meta property="article:tag" content="Python">
  <meta property="article:tag" content="Spider">
  <meta property="article:tag" content="爬虫">
  <meta property="article:tag" content="Web">
  <meta property="article:tag" content="Kubernetes">
  <meta property="article:tag" content="深度学习">
  <meta property="article:tag" content="机器学习">
  <meta property="article:tag" content="数据分析">
  <meta property="article:tag" content="网络">
  <meta property="article:tag" content="IT">
  <meta property="article:tag" content="技术">
  <meta property="article:tag" content="博客">
  <meta name="twitter:card" content="summary">
  <link rel="canonical" href="https://cuiqingcai.com/page/3/">
  <script id="page-configurations">
    // https://hexo.io/docs/variables.html
    CONFIG.page = {
      sidebar: "",
      isHome: true,
      isPost: false,
      lang: 'zh-CN'
    };

  </script>
  <title>静觅丨崔庆才的个人站点</title>
  <meta name="google-site-verification" content="p_bIcnvirkFzG2dYKuNDivKD8-STet5W7D-01woA2fc" />
  <noscript>
    <style>
      .use-motion .brand,
      .use-motion .menu-item,
      .sidebar-inner,
      .use-motion .post-block,
      .use-motion .pagination,
      .use-motion .comments,
      .use-motion .post-header,
      .use-motion .post-body,
      .use-motion .collection-header
      {
        opacity: initial;
      }

      .use-motion .site-title,
      .use-motion .site-subtitle
      {
        opacity: initial;
        top: initial;
      }

      .use-motion .logo-line-before i
      {
        left: initial;
      }

      .use-motion .logo-line-after i
      {
        right: initial;
      }

    </style>
  </noscript>
  <link rel="alternate" href="/atom.xml" title="静觅" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container">
    <div class="headband"></div>
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner">
        <div class="site-brand-container">
          <div class="site-nav-toggle">
            <div class="toggle" aria-label="切换导航栏">
              <span class="toggle-line toggle-line-first"></span>
              <span class="toggle-line toggle-line-middle"></span>
              <span class="toggle-line toggle-line-last"></span>
            </div>
          </div>
          <div class="site-meta">
            <a href="/" class="brand" rel="start">
              <span class="logo-line-before"><i></i></span>
              <h1 class="site-title">静觅 <span class="site-subtitle"> 崔庆才的个人站点 </span>
              </h1>
              <span class="logo-line-after"><i></i></span>
            </a>
          </div>
          <div class="site-nav-right">
            <div class="toggle popup-trigger">
              <i class="fa fa-search fa-fw fa-lg"></i>
            </div>
          </div>
        </div>
        <nav class="site-nav">
          <ul id="menu" class="main-menu menu">
            <li class="menu-item menu-item-home">
              <a href="/" rel="section">首页</a>
            </li>
            <li class="menu-item menu-item-archives">
              <a href="/archives/" rel="section">文章列表</a>
            </li>
            <li class="menu-item menu-item-tags">
              <a href="/tags/" rel="section">文章标签</a>
            </li>
            <li class="menu-item menu-item-categories">
              <a href="/categories/" rel="section">文章分类</a>
            </li>
            <li class="menu-item menu-item-about">
              <a href="/about/" rel="section">关于博主</a>
            </li>
            <li class="menu-item menu-item-message">
              <a href="/message/" rel="section">给我留言</a>
            </li>
            <li class="menu-item menu-item-search">
              <a role="button" class="popup-trigger">搜索 </a>
            </li>
          </ul>
        </nav>
        <div class="search-pop-overlay">
          <div class="popup search-popup">
            <div class="search-header">
              <span class="search-icon">
                <i class="fa fa-search"></i>
              </span>
              <div class="search-input-container">
                <input autocomplete="off" autocapitalize="off" placeholder="搜索..." spellcheck="false" type="search" class="search-input">
              </div>
              <span class="popup-btn-close">
                <i class="fa fa-times-circle"></i>
              </span>
            </div>
            <div id="search-result">
              <div id="no-result">
                <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
              </div>
            </div>
          </div>
        </div>
      </div>
    </header>
    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
      <span>0%</span>
    </div>
    <div class="reading-progress-bar"></div>
    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div class="content index posts-expand">
            <div class="carousel">
              <div id="wowslider-container">
                <div class="ws_images">
                  <ul>
                    <li><a target="_blank" href="https://cuiqingcai.com/5052.html"><img title="Python3网络爬虫开发实战教程" src="https://qiniu.cuiqingcai.com/ipy96.jpg" /></a></li>
                    <li><a target="_blank" href="https://t.lagou.com/fRCBRsRCSN6FA"><img title="52讲轻松搞定网络爬虫" src="https://qiniu.cuiqingcai.com/fqq5e.png" /></a></li>
                    <li><a target="_blank" href="https://brightdata.grsm.io/cuiqingcai"><img title="亮网络解锁器" src="https://qiniu.cuiqingcai.com/6qnb7.png" /></a></li>
                    <li><a target="_blank" href="https://cuiqingcai.com/4320.html"><img title="Python3网络爬虫开发视频教程" src="https://qiniu.cuiqingcai.com/bjrny.jpg" /></a></li>
                    <li><a target="_blank" href="https://cuiqingcai.com/5094.html"><img title="爬虫代理哪家强？十大付费代理详细对比评测出炉！" src="https://qiniu.cuiqingcai.com/nifs6.jpg" /></a></li>
                  </ul>
                </div>
                <div class="ws_thumbs">
                  <div>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/ipy96.jpg" /></a>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/fqq5e.png" /></a>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/6qnb7.png" /></a>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/bjrny.jpg" /></a>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/nifs6.jpg" /></a>
                  </div>
                </div>
                <div class="ws_shadow"></div>
              </div>
            </div>
            <link rel="stylesheet" href="/lib/wowslide/slide.css">
            <script src="/lib/wowslide/jquery.min.js"></script>
            <script src="/lib/wowslide/slider.js"></script>
            <script>
              jQuery("#wowslider-container").wowSlider(
              {
                effect: "cube",
                prev: "",
                next: "",
                duration: 20 * 100,
                delay: 20 * 100,
                width: 716,
                height: 297,
                autoPlay: true,
                playPause: true,
                stopOnHover: false,
                loop: false,
                bullets: 0,
                caption: true,
                captionEffect: "slide",
                controls: true,
                onBeforeStep: 0,
                images: 0
              });

            </script>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31072.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31072.html" class="post-title-link" itemprop="url">Playwright 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Playwright 是微软开源的自动化测试工具，也可以用作网络爬虫。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/microsoft/playwright" target="_blank" rel="noopener">https://github.com/microsoft/playwright</a></li>
                    <li>官方文档：<a href="https://playwright.dev/python/docs/intro" target="_blank" rel="noopener">https://playwright.dev/python/docs/intro</a></li>
                  </ul>
                  <h2 id="安装方法"><a href="#安装方法" class="headerlink" title="安装方法"></a>安装方法</h2>
                  <h3 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h3>
                  <p>推荐使用 pip3 安装，命令如下：</p>
                  <figure class="highlight sql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> <span class="comment">--upgrade pip</span></span><br><span class="line">pip3 <span class="keyword">install</span> playwright</span><br><span class="line">playwright <span class="keyword">install</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>命令执行完毕之后即可完成安装，其中最后一条命令，Playwright 会完成一些初始化的工作，比如下载必要的浏览器和配置对应驱动、环境变量等。</p>
                  <h3 id="conda-安装"><a href="#conda-安装" class="headerlink" title="conda 安装"></a>conda 安装</h3>
                  <p>也可以使用 conda 安装，安装命令如下：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">conda<span class="built_in"> config </span>--<span class="builtin-name">add</span> channels conda-forge</span><br><span class="line">conda<span class="built_in"> config </span>--<span class="builtin-name">add</span> channels microsoft</span><br><span class="line">conda install playwright</span><br><span class="line">playwright install</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>效果是一样的。</p>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>安装完成之后，可以在 Python 命令行下测试。</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span><span class="keyword">import</span> playwright</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果没有错误报出，则证明库已经安装好了。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 17:31:41" itemprop="dateCreated datePublished" datetime="2021-10-03T17:31:41+08:00">2021-10-03</time>
                </span>
                <span id="/31072.html" class="post-meta-item leancloud_visitors" data-flag-title="Playwright 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>518</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31070.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31070.html" class="post-title-link" itemprop="url">MongoDB 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>MongoDB 是由 C++ 语言编写的非关系型数据库，是一个基于分布式文件存储的开源数据库系统，其内容存储形式类似 Json 对象，它的字段值可以包含其他文档，数组及文档数组，非常灵活。</p>
                  <p>MongoDB 支持多种平台，包括 Windows、Linux、Mac OS、Solaris 等，在其官方网站均可找到对应的安装包，<a href="https://www.mongodb.com/download-center" target="_blank" rel="noopener">https://www.mongodb.com/download-center</a></p>
                  <p>本节我们来看下它的安装过程。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://www.mongodb.com" target="_blank" rel="noopener">https://www.mongodb.com</a></li>
                    <li>官方文档：<a href="https://docs.mongodb.com" target="_blank" rel="noopener">https://docs.mongodb.com</a></li>
                    <li>GitHub：<a href="https://github.com/mongodb" target="_blank" rel="noopener">https://github.com/mongodb</a></li>
                    <li>中文教程：<a href="http://www.runoob.com/mongodb/mongodb-tutorial.html" target="_blank" rel="noopener">http://www.runoob.com/mongodb/mongodb-tutorial.html</a></li>
                  </ul>
                  <h2 id="安装方法"><a href="#安装方法" class="headerlink" title="安装方法"></a>安装方法</h2>
                  <h3 id="Windows-下的安装"><a href="#Windows-下的安装" class="headerlink" title="Windows 下的安装"></a>Windows 下的安装</h3>
                  <p>直接在官网下载安装包即可，链接为：<a href="https://www.mongodb.com/try/download/community，页面如图所示：" target="_blank" rel="noopener">https://www.mongodb.com/try/download/community，页面如图所示：</a></p>
                  <p><img src="https://qiniu.cuiqingcai.com/jg9d0.png" alt=""></p>
                  <p>直接点击 Download 下载 msi 安装包即可。</p>
                  <p>下载完成之后双击开始安装，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/6f830.png" alt=""></p>
                  <p>后面的安装模式选择 Complete 即可，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/9dzx0.png" alt=""></p>
                  <p>点击之后可以看到一些 MongoDB 安装配置，如 data 文件夹、log 文件夹都在哪里，还有是否把 MongoDB 安装成系统服务，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/nco9m.png" alt=""></p>
                  <p>一直点击下一步安装即可。</p>
                  <p>安装完毕之后 MongoDB 也会被注册成一个 Windows 服务，而且已经启动，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/o13na.png" alt=""></p>
                  <p>这里我们可以控制服务的开关，即 MongoDB 服务的开关。</p>
                  <p>这样 Windows 下 MongoDB 配置就完成了。</p>
                  <h2 id="Linux-下的安装"><a href="#Linux-下的安装" class="headerlink" title="Linux 下的安装"></a>Linux 下的安装</h2>
                  <p>完整的安装教程请参考：<a href="https://docs.mongodb.com/manual/administration/install-on-linux/，如下内容仅作参考。" target="_blank" rel="noopener">https://docs.mongodb.com/manual/administration/install-on-linux/，如下内容仅作参考。</a></p>
                  <p>在这里以 MongoDB 5.0 为例说明 MongoDB 的安装过程。</p>
                  <h3 id="Ubuntu"><a href="#Ubuntu" class="headerlink" title="Ubuntu"></a>Ubuntu</h3>
                  <p>首先导入 MongoDB 的 GPG Key：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">wget -qO - https://www.mongodb.org/static/pgp/<span class="keyword">server</span><span class="number">-5.0</span>.<span class="keyword">asc</span> | sudo apt-key <span class="keyword">add</span> -</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>随后创建 apt-get 源列表，各个系统版本对应的命令如下：</p>
                  <ul>
                    <li>Ubuntu 20.04</li>
                  </ul>
                  <figure class="highlight lsl">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">echo <span class="string">"deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse"</span> | sudo tee /etc/apt/sources.<span class="type">list</span>.d/mongodb-org<span class="number">-5.0</span>.<span class="type">list</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <ul>
                    <li>Ubuntu 18.04</li>
                  </ul>
                  <figure class="highlight lsl">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">echo <span class="string">"deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse"</span> | sudo tee /etc/apt/sources.<span class="type">list</span>.d/mongodb-org<span class="number">-5.0</span>.<span class="type">list</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>随后更新 apt-get 源：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="keyword">get</span> <span class="keyword">update</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>之后安装 MongoDB 即可：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="builtin-name">get</span> install -y mongodb-org</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>安装完成之后运行 MongoDB，命令如下：</p>
                  <figure class="highlight crmsh">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo systemctl <span class="literal">start</span> mongod</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行命令之后 MongoDB 就在 27017 端口上运行了，数据文件会保存在 /data/db 路径下。</p>
                  <p>一般我们在 Linux 上配置 MongoDB 都是为了远程连接使用的，所以在这里还需要配置一下 MongoDB 的远程连接和用户名密码：</p>
                  <p>接着我们进入到 MongoDB 命令行：</p>
                  <figure class="highlight ada">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">mongo <span class="comment">--port 27017</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>现在我们就已经进入到 MongoDB 的命令行交互模式下了，在此模式下运行如下命令：</p>
                  <figure class="highlight groovy">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">&gt; use admin</span><br><span class="line">switched to db admin</span><br><span class="line">&gt; db.createUser(&#123;<span class="string">user:</span> <span class="string">'admin'</span>, <span class="string">pwd:</span> <span class="string">'admin123'</span>, <span class="string">roles:</span> [&#123;<span class="string">role:</span> <span class="string">'root'</span>, <span class="string">db:</span> <span class="string">'admin'</span>&#125;]&#125;)</span><br><span class="line">Successfully added <span class="string">user:</span> &#123;</span><br><span class="line">        <span class="string">"user"</span> : <span class="string">"admin"</span>,</span><br><span class="line">        <span class="string">"roles"</span> : [</span><br><span class="line">                &#123;</span><br><span class="line">                        <span class="string">"role"</span> : <span class="string">"root"</span>,</span><br><span class="line">                        <span class="string">"db"</span> : <span class="string">"admin"</span></span><br><span class="line">                &#125;</span><br><span class="line">        ]</span><br><span class="line">&#125;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样我们就创建了一个用户名为 admin，密码为 admin123 的用户，赋予最高权限。</p>
                  <p>随后需要修改 MongoDB 的配置文件，</p>
                  <p>执行如下命令：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo <span class="keyword">vi</span> /etc/mongod.<span class="keyword">conf</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>修改 net 部分为：</p>
                  <figure class="highlight yaml">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attr">net:</span></span><br><span class="line">  <span class="attr">port:</span> <span class="number">27017</span></span><br><span class="line">  <span class="attr">bindIp:</span> <span class="number">0.0</span><span class="number">.0</span><span class="number">.0</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样配置后 MongoDB 可被远程访问。</p>
                  <p>另外还需要添加如下权限认证配置，直接添加如下内容到配置文件：</p>
                  <figure class="highlight dts">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="symbol">security:</span></span><br><span class="line"><span class="symbol"> authorization:</span> enabled</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>配置完成之后我们需要重新启动 MongoDB 服务，命令如下：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo<span class="built_in"> service </span>mongod restart</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样远程连接和权限认证就配置完成了。</p>
                  <h3 id="CentOS、RedHat"><a href="#CentOS、RedHat" class="headerlink" title="CentOS、RedHat"></a>CentOS、RedHat</h3>
                  <p>首先添加 MongoDB 源：</p>
                  <figure class="highlight awk">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo vi <span class="regexp">/etc/yum</span>.repos.d<span class="regexp">/mongodb-org.repo</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>修改为如下内容保存：</p>
                  <figure class="highlight ini">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="section">[mongodb-org-5.0]</span></span><br><span class="line"><span class="attr">name</span>=MongoDB Repository</span><br><span class="line"><span class="attr">baseurl</span>=https://repo.mongodb.org/yum/redhat/<span class="variable">$releasever</span>/mongodb-org/<span class="number">5.0</span>/x<span class="number">86_64</span>/</span><br><span class="line"><span class="attr">gpgcheck</span>=<span class="number">1</span></span><br><span class="line"><span class="attr">enabled</span>=<span class="number">1</span></span><br><span class="line"><span class="attr">gpgkey</span>=https://www.mongodb.org/static/pgp/server-<span class="number">5.0</span>.asc</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后执行 yum 命令安装：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo yum <span class="keyword">install</span> mongodb-org</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>启动 MongoDB 服务：</p>
                  <figure class="highlight crmsh">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo systemctl <span class="literal">start</span> mongod</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>停止和重新加载 MongoDB 服务：</p>
                  <figure class="highlight properties">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attr">sudo</span> <span class="string">systemctl stop mongod</span></span><br><span class="line"><span class="attr">sudo</span> <span class="string">systemctl reload mongod</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>有关远程连接和认证配置可以参考上文，方式是相同的。</p>
                  <p>更多 Linux 发行版的 MongoDB 安装方式可以参考官方文档：<a href="https://docs.mongodb.com/manual/administration/install-on-linux/。" target="_blank" rel="noopener">https://docs.mongodb.com/manual/administration/install-on-linux/。</a></p>
                  <h2 id="Mac-下的安装"><a href="#Mac-下的安装" class="headerlink" title="Mac 下的安装"></a>Mac 下的安装</h2>
                  <p>完整安装说明请参考：<a href="https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/，如下内容仅作参考。" target="_blank" rel="noopener">https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/，如下内容仅作参考。</a></p>
                  <p>首先确保一些依赖库已经正确安装了，运行如下命令：</p>
                  <figure class="highlight ada">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">xcode-<span class="keyword">select</span> <span class="comment">--install</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>推荐使用 Homebrew 安装，执行 brew 命令即可：</p>
                  <figure class="highlight armasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span>tap mongodb/<span class="keyword">brew</span></span><br><span class="line"><span class="keyword">brew </span>install mongodb-community<span class="comment">@5.0</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后创建一个新文件夹 /data/db，用于存放 MongoDB 数据。</p>
                  <p>启动 MongoDB 服务：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">brew services start mongodb-<span class="symbol">community@</span><span class="number">5.0</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样就启动了 MongoDB 服务。</p>
                  <p>停止、重启 MongoDB 服务的命令：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">brew services stop mongodb-<span class="symbol">community@</span><span class="number">5.0</span></span><br><span class="line">brew services restart mongodb-<span class="symbol">community@</span><span class="number">5.0</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="可视化工具"><a href="#可视化工具" class="headerlink" title="可视化工具"></a>可视化工具</h2>
                  <p>在这里推荐一个可视化工具 RoboMongo/Robo 3T，使用简单，功能强大，官方网站：<a href="https://robomongo.org/" target="_blank" rel="noopener">https://robomongo.org/</a>，三大平台都有支持，下载链接：<a href="https://robomongo.org/download" target="_blank" rel="noopener">https://robomongo.org/download</a>。</p>
                  <p>另外还有一个简单易用的可视化工具，Studio 3T，同样具有方便的图形化管理，官方网站：<a href="https://studio3t.com" target="_blank" rel="noopener">https://studio3t.com</a>，同样支持三大平台，下载链接：<a href="https://studio3t.com/download/" target="_blank" rel="noopener">https://studio3t.com/download/</a>。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 16:31:41" itemprop="dateCreated datePublished" datetime="2021-10-03T16:31:41+08:00">2021-10-03</time>
                </span>
                <span id="/31070.html" class="post-meta-item leancloud_visitors" data-flag-title="MongoDB 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>3.3k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>3 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31071.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31071.html" class="post-title-link" itemprop="url">Splash 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Splash 是一个 JavaScript 渲染的工具，本节来介绍一下它的安装方式。</p>
                  <h2 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h2>
                  <p>Splash 建议的安装方式是通过 Docker，安装是通过 Docker 安装，在这之前请确保已经正确安装好了 Docker，可以参考：<a href="https://setup.scrape.center/docker。" target="_blank" rel="noopener">https://setup.scrape.center/docker。</a></p>
                  <h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2>
                  <p>有了 Docker，只需要一键启动 Splash 即可，命令如下：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run -p <span class="number">8050</span>:<span class="number">8050</span> scrapinghub/splash</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>安装完成之后会有类似的输出结果：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/nqfy3.png" alt=""></p>
                  <p>这样就证明 Splash 已经在 8050 端口上运行了。</p>
                  <p>这时我们打开：<a href="http://localhost:8050" target="_blank" rel="noopener">http://localhost:8050</a> 即可看到 Splash 的主页，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/umgr5.png" alt=""></p>
                  <p>当然 Splash 也可以直接安装在远程服务器上，我们在服务器上运行以守护态运行 Splash 即可，命令如下：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run -d -p <span class="number">8050</span>:<span class="number">8050</span> scrapinghub/splash</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>在这里多了一个 -d 参数，它代表将 Docker 容器以守护态运行，这样在中断远程服务器连接后不会终止 Splash 服务的运行。</p>
                  <p>完毕！</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 16:31:41" itemprop="dateCreated datePublished" datetime="2021-10-03T16:31:41+08:00">2021-10-03</time>
                </span>
                <span id="/31071.html" class="post-meta-item leancloud_visitors" data-flag-title="Splash 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>457</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31069.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31069.html" class="post-title-link" itemprop="url">MySQL 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>MySQL 是一个轻量级的关系型数据库，以表的形式来存储数据，本节我们来了解下它的安装方式。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://www.mysql.com/cn" target="_blank" rel="noopener">https://www.mysql.com/cn</a></li>
                    <li>下载地址：<a href="https://www.mysql.com/cn/downloads" target="_blank" rel="noopener">https://www.mysql.com/cn/downloads</a></li>
                    <li>中文教程：<a href="http://www.runoob.com/mysql/mysql-tutorial.html" target="_blank" rel="noopener">http://www.runoob.com/mysql/mysql-tutorial.html</a></li>
                  </ul>
                  <h2 id="Windows-下的安装"><a href="#Windows-下的安装" class="headerlink" title="Windows 下的安装"></a>Windows 下的安装</h2>
                  <p>对于 Windows 来说，最安全稳妥的方式就是直接到官网下载安装包进行安装。可以访问官方网站下载，<a href="https://dev.mysql.com/downloads/mysql/" target="_blank" rel="noopener">https://dev.mysql.com/downloads/mysql/</a>，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/kgztx.png" alt=""></p>
                  <p>点击最大的 MySQL Installer 即可，然后选择第二个选项 - mysql-installer-community-8.0.26.0.msi 下载即可，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/9syq3.png" alt=""></p>
                  <p>此时会要求登录 MySQL 的账号，这里可以登录或者选择直接下载，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/cv4wv.png" alt=""></p>
                  <p>下载之后会得到一个 msi 后缀的安装文件，直接双击运行安装，直接选择默认选项点击下一步安装即可，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/dimme.png" alt=""></p>
                  <p>这里直接选择默认选项即可，然后点下一步。</p>
                  <p>下一页需要确认下需要安装的内容，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/l7d3m.png" alt=""></p>
                  <p>保持默认配置即可，然后点击 Execute 即可。</p>
                  <p>安装完成之后 MySQL Installer 会引导我们进行一些配置，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/gfexj.png" alt=""></p>
                  <p>此页面需要配置一些网络环境和端口，保持默认即可，点击下一步。</p>
                  <p>下一步是使用怎样的密码加密方式，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/ticce.png" alt=""></p>
                  <p>这里也是使用默认配置即可，可以点击下一步。</p>
                  <p>下一步就是配置用户名和密码，这里我们可以配置 Root 账户的密码，也可以自定义用户来配置，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/0y3bc.png" alt=""></p>
                  <p>输入密码之后，点击下一步即可。</p>
                  <p>接下来就是服务的配置，这里默认配置是把 MySQL 服务配置成 Windows 服务中，而且在每次系统启动的时候都自动启动 MySQL 服务，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/mohrk.png" alt=""></p>
                  <p>如果我们想要每次开机的时候都自动启用 MySQL 服务，那我们可以勾选上 Start the MySQL Server at System Startup，否则勾选，配置好了之后点击下一步即可。</p>
                  <p>最后一步就是应用刚才的服务，使得服务生效，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/207k3.png" alt=""></p>
                  <p>这里我们直接点击 Execute 即可。</p>
                  <p>安装之后我们会发现刚才还附带安装了一个 MySQL Workbench，就是 MySQL 可视化管理的客户端，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/mpdz6.png" alt=""></p>
                  <p>这里可以发现已经添加了一个本地的 MySQL 服务的连接，双击即可连接。</p>
                  <p>连接之后我们还可以选中某个数据库的某个表，选择查看数据的选项 Select Rows，查看表中中的前 100 条数据，这样数据就被查询出来了，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/fm5ih.png" alt=""></p>
                  <p>安装完成之后我们可以在电脑-管理-服务页面开启和关闭 MySQL 服务，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/od3an.png" alt=""></p>
                  <p>如果启动了 MySQL 服务，那么我们就可以使用它来进行数据存储了。</p>
                  <h2 id="Linux-下的安装"><a href="#Linux-下的安装" class="headerlink" title="Linux 下的安装"></a>Linux 下的安装</h2>
                  <p>下面仍然分不同平台进行介绍。</p>
                  <h3 id="Ubuntu、Debian、Deepin"><a href="#Ubuntu、Debian、Deepin" class="headerlink" title="Ubuntu、Debian、Deepin"></a>Ubuntu、Debian、Deepin</h3>
                  <p>直接使用 apt-get 命令即可下载安装:</p>
                  <figure class="highlight sql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-get <span class="keyword">update</span></span><br><span class="line">sudo apt-<span class="keyword">get</span> <span class="keyword">install</span> -y mysql-<span class="keyword">server</span> mysql-<span class="keyword">client</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>在安装过程中会提示输入用户名密码，输入之后等待片刻即可完成安装。</p>
                  <p>启动、关闭、重启 MySQL 服务命令：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo<span class="built_in"> service </span>mysql start</span><br><span class="line">sudo<span class="built_in"> service </span>mysql stop</span><br><span class="line">sudo<span class="built_in"> service </span>mysql restart</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="CentOS、RedHat"><a href="#CentOS、RedHat" class="headerlink" title="CentOS、RedHat"></a>CentOS、RedHat</h3>
                  <p>完整的安装说明可以参考：<a href="https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7" target="_blank" rel="noopener">https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7</a></p>
                  <p>以 MySQL 5.7 的 Yum 源为例，如果需要更高版本可以另寻，安装命令如下：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">wget https://dev.mysql.com/<span class="keyword">get</span>/mysql57-community-<span class="keyword">release</span>-el7<span class="number">-9.</span>noarch.rpm</span><br><span class="line">sudo rpm -ivh mysql-community-<span class="keyword">release</span>-el7<span class="number">-5.</span>noarch.rpm</span><br><span class="line">yum install -y mysql mysql-<span class="keyword">server</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行如上命令即可完成安装，初始密码为空。接下来需要启动 MySQL 服务。</p>
                  <p>启动 MySQL 服务命令：</p>
                  <figure class="highlight crmsh">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo systemctl <span class="literal">start</span> mysqld</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>停止、重启命令：</p>
                  <figure class="highlight properties">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attr">sudo</span> <span class="string">systemctl stop mysqld</span></span><br><span class="line"><span class="attr">sudo</span> <span class="string">systemctl restart mysqld</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>以上我们就完成了 Linux 下 MySQL 的安装，安装完成之后可以修改密码，可以执行如下命令：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">mysql -uroot -p</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>输入密码后进入 MySQL 命令行模式。</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">use mysql;</span><br><span class="line">UPDATE<span class="built_in"> user </span><span class="builtin-name">SET</span> Password = PASSWORD(<span class="string">'newpass'</span>) WHERE<span class="built_in"> user </span>= <span class="string">'root'</span>;</span><br><span class="line">FLUSH PRIVILEGES;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>命令中 newpass 即为修改的新的 MySQL 密码，请自行替换。</p>
                  <p>由于 Linux 一般会作为服务器使用，为了使得 MySQL 可以被远程访问，我们需要修改 MySQL 的配置文件，配置文件路径一般为 /etc/mysql/my.cnf。</p>
                  <p>如使用 vi 进行修改的命令如下：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">vi</span> /etc/mysql/my.<span class="keyword">cnf</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>取消此行的注释：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">bind-address = <span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>此行限制了 MySQL 只能本地访问而不能远程访问，取消注释即可解除此限制。</p>
                  <p>修改完成之后重启 MySQL 服务，这样 MySQL 就可以被远程访问了。</p>
                  <p>到此为止，Linux 下安装 MySQL 的过程结束。</p>
                  <h2 id="Mac-下的安装"><a href="#Mac-下的安装" class="headerlink" title="Mac 下的安装"></a>Mac 下的安装</h2>
                  <p>推荐使用 Homebrew 安装，执行 brew 命令即可。</p>
                  <figure class="highlight mipsasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span><span class="keyword">install </span>mysql</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>启动、停止、重启 MySQL 服务的命令：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo mysql.<span class="keyword">server</span> <span class="keyword">start</span></span><br><span class="line">sudo mysql.<span class="keyword">server</span> stop</span><br><span class="line">sudo mysql.<span class="keyword">server</span> <span class="keyword">restart</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>Mac 一般不会作为服务器使用，如果要想取消本地 host 绑定，同样修改 my.cnf 文件，然后重启服务即可。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 16:29:41" itemprop="dateCreated datePublished" datetime="2021-10-03T16:29:41+08:00">2021-10-03</time>
                </span>
                <span id="/31069.html" class="post-meta-item leancloud_visitors" data-flag-title="MySQL 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>2.4k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>2 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31055.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31055.html" class="post-title-link" itemprop="url">Appium 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Appium 是移动端的自动化测试工具，类似于前面所说的 Selenium，利用它我们可以驱动 Android、iOS 等设备完成自动化测试，比如模拟点击、滑动、输入等操作，其官方网站为：<a href="http://appium.io/" target="_blank" rel="noopener">http://appium.io/</a>，本节来了解一下 Appium 的安装方式。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/appium/appium" target="_blank" rel="noopener">https://github.com/appium/appium</a></li>
                    <li>官方网站：<a href="http://appium.io" target="_blank" rel="noopener">http://appium.io</a></li>
                    <li>官方文档：<a href="http://appium.io/introduction.html" target="_blank" rel="noopener">http://appium.io/introduction.html</a></li>
                    <li>下载链接：<a href="https://github.com/appium/appium-desktop/releases" target="_blank" rel="noopener">https://github.com/appium/appium-desktop/releases</a></li>
                    <li>Python Client：<a href="https://github.com/appium/python-client" target="_blank" rel="noopener">https://github.com/appium/python-client</a></li>
                  </ul>
                  <h2 id="安装-Appium"><a href="#安装-Appium" class="headerlink" title="安装 Appium"></a>安装 Appium</h2>
                  <p>首先我们需要安装 Appium，Appium 负责驱动移动端来完成一系列操作，对 iOS 设备来说，它使用苹果的 UIAutomation 来实现驱动，对于 Android 来说，它使用 UiAutomator 和 Selendroid 来实现驱动。</p>
                  <p>同时 Appium 也相当于一个服务器，我们可以向 Appium 发送一些操作指令，Appium 就会根据不同的指令对移动设备进行驱动，完成不同的动作。</p>
                  <p>安装 Appium 有两种方式，一种是直接下载安装包 Appium Desktop 来安装，另外一种是通过 Node.js 来安装，下面我们各自介绍一下两种安装方式。</p>
                  <h3 id="Appium-Desktop"><a href="#Appium-Desktop" class="headerlink" title="Appium Desktop"></a>Appium Desktop</h3>
                  <p>Appium Desktop 支持全平台的安装，我们直接从 GitHub 的 Releases 里面安装即可，链接为：<a href="https://github.com/appium/appium-desktop/releases" target="_blank" rel="noopener">https://github.com/appium/appium-desktop/releases</a>，目前的最新版本是 1.22，最新版本以网站为准，下载页面如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/jrut8.png" alt=""></p>
                  <p>Windows 平台可以下载 exe 安装包如 <a href="https://github.com/appium/appium-desktop/releases/download/v1.22.0/Appium-Server-GUI-windows-1.22.0.exe" target="_blank" rel="noopener">Appium-Server-GUI-windows-1.22.0.exe</a>，Mac 平台可以下载 dmg 安装包如 <a href="https://github.com/appium/appium-desktop/releases/download/v1.22.0/Appium-Server-GUI-mac-1.22.0.dmg" target="_blank" rel="noopener">Appium-Server-GUI-mac-1.22.0.dmg</a>，Linux 平台可以选择下载源码，但是更推荐用下文的 Node.js 安装方式。</p>
                  <p>安装完成之后运行之后页面如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/jqwvk.jpg" alt=""></p>
                  <p>如果出现此页面则证明安装成功。</p>
                  <h3 id="Node-js"><a href="#Node-js" class="headerlink" title="Node.js"></a>Node.js</h3>
                  <p>首先需要安装 Node.js，具体的安装方式可以参见：<a href="http://www.runoob.com/nodejs/nodejs-install-setup.html" target="_blank" rel="noopener">http://www.runoob.com/nodejs/nodejs-install-setup.html</a>，安装完成之后就可以使用 npm 命令了。</p>
                  <p>接下来使用 npm 命令全局安装 Appium 即可，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">npm <span class="keyword">install</span> -g appium</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>等待命令执行执行完成即可，这样就成功安装了 Appium。</p>
                  <h2 id="Android-开发环境配置"><a href="#Android-开发环境配置" class="headerlink" title="Android 开发环境配置"></a>Android 开发环境配置</h2>
                  <p>如果我们要使用 Android 设备做 App 抓取的话，还需要下载和配置 Android SDK，在这里推荐直接安装 Android Studio，其下载地址为：<a href="https://developer.android.com/studio/index.html?hl=zh-cn" target="_blank" rel="noopener">https://developer.android.com/studio/index.html?hl=zh-cn</a>，下载之后直接安装即可。</p>
                  <p>完成之后我们还需要下载 Android SDK，直接打开首选项里面的 Android SDK 设置页面，勾选要安装的 SDK 版本，点击确定即可开始下载和安装勾选的 SDK 版本，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/aix32.jpg" alt=""></p>
                  <p>另外还需要配置一下环境变量，添加 ANDROID_HOME 为 Android SDK 所在路径，然后再添加 SDK 文件夹下的 tools 和 platform-tools 文件夹到 PATH 中。</p>
                  <p>更详细的配置可以参考 Android Studio 的官方文档：<a href="https://developer.android.com/studio/intro/index.html" target="_blank" rel="noopener">https://developer.android.com/studio/intro/index.html</a>。</p>
                  <h2 id="iOS-开发环境配置"><a href="#iOS-开发环境配置" class="headerlink" title="iOS 开发环境配置"></a>iOS 开发环境配置</h2>
                  <p>首先需要声明的是，Appium 是一个做自动化测试的工具，用它来测试我们自己开发的 App 是完全没问题的，它携带的是开发者证书（Development Certificate）。但如果我们想拿 iOS 设备来做数据爬取的话又是另外一回事了，一般我们做数据爬取都是使用现有的 APP，在 iOS 上一般都是通过 App Store 下载的，它携带的是分发证书（Distribution Certificate），而携带这种证书的应用都是禁止被测试的，所以只有获取 ipa 安装包再重新签名之后才可以被 Appium 测试，具体的方法不再展开阐述，如感兴趣可以搜索相关资料。</p>
                  <p>因此在这里推荐直接使用 Android 来进行测试，如果你可以完成上述操作重签名操作，那么可以参考如下内容配置 iOS 开发环境。</p>
                  <p>Appium 驱动 iOS 设备必须要在 Mac 下进行，Windows 和 Linux 是平台是无法完成的，下面只介绍一下 Mac 平台的相关配置。</p>
                  <p>Mac 平台需要的配置如下：</p>
                  <ul>
                    <li>Mac OS X 10.12 及更高版本</li>
                    <li>XCode 8 及更高版本</li>
                  </ul>
                  <p>配置满足要求之后执行如下命令即可配置开发依赖的一些库和工具：</p>
                  <figure class="highlight ada">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">xcode-<span class="keyword">select</span> <span class="comment">--install</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样 iOS 部分开发环境就配置完成了，我们就可以用 iOS 模拟器来进行测试和数据抓取了。</p>
                  <p>如果想要用真机进行测试和数据抓取，还需要额外配置一下其他的环境，可以参考：<a href="https://github.com/appium/appium/blob/master/docs/en/appium-setup/real-devices-ios.md" target="_blank" rel="noopener">https://github.com/appium/appium/blob/master/docs/en/appium-setup/real-devices-ios.md</a>。</p>
                  <h2 id="结语"><a href="#结语" class="headerlink" title="结语"></a>结语</h2>
                  <p>以上是 Appium 开发环境的搭建，在后文我们会用它来抓取微信朋友圈的内容。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 12:41:41" itemprop="dateCreated datePublished" datetime="2021-10-03T12:41:41+08:00">2021-10-03</time>
                </span>
                <span id="/31055.html" class="post-meta-item leancloud_visitors" data-flag-title="Appium 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>2.2k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>2 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31054.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31054.html" class="post-title-link" itemprop="url">Docker 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Docker 是一种容器技术，它可以将应用和环境等进行打包，形成一个独立的，类似于 iOS 的 APP 形式的「应用」，这个应用可以直接被分发到任意一个支持 Docker 的环境中，通过简单的命令即可启动运行。Docker 是一种最流行的容器化实现方案。和虚拟化技术类似，它极大的方便了应用服务的部署；又与虚拟化技术不同，它以一种更轻量的方式实现了应用服务的打包。使用 Docker 可以让每个应用彼此相互隔离，在同一台机器上同时运行多个应用，不过他们彼此之间共享同一个操作系统。Docker 的优势在于，它可以在更细的粒度上进行资源的管理，也比虚拟化技术更加节约资源。</p>
                  <p>本段参考：<a href="http://guide.daocloud.io/dcs/docker-9152673.html" target="_blank" rel="noopener">DaoCloud 官方文档</a></p>
                  <p>对于爬虫来说，如果我们需要大规模部署爬虫系统的话，用 Docker 会大大提高效率，工欲善其事，必先利其器。</p>
                  <p>本节来介绍一下三大平台下 Docker 的安装方式。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://www.docker.com" target="_blank" rel="noopener">https://www.docker.com</a></li>
                    <li>GitHub：<a href="https://github.com/docker" target="_blank" rel="noopener">https://github.com/docker</a></li>
                    <li>Docker Hub：<a href="https://hub.docker.com" target="_blank" rel="noopener">https://hub.docker.com</a></li>
                    <li>官方文档：<a href="https://docs.docker.com" target="_blank" rel="noopener">https://docs.docker.com</a></li>
                    <li>DaoCloud：<a href="http://www.daocloud.io" target="_blank" rel="noopener">http://www.daocloud.io</a></li>
                    <li>中文社区：<a href="http://www.docker.org.cn" target="_blank" rel="noopener">http://www.docker.org.cn</a></li>
                    <li>中文教程：<a href="http://www.runoob.com/docker/docker-tutorial.html" target="_blank" rel="noopener">http://www.runoob.com/docker/docker-tutorial.html</a></li>
                    <li>推荐书籍：<a href="https://yeasy.gitbooks.io/docker_practice" target="_blank" rel="noopener">https://yeasy.gitbooks.io/docker_practice</a></li>
                  </ul>
                  <h2 id="Windows-下的安装"><a href="#Windows-下的安装" class="headerlink" title="Windows 下的安装"></a>Windows 下的安装</h2>
                  <p>如果你的系统是 Windows10 64 位，那么推荐使用 Docker for Windows，直接从 Docker 官方网站下载最新的 Docker for Windows 安装包即可：<a href="https://docs.docker.com/docker-for-windows/install/" target="_blank" rel="noopener">https://docs.docker.com/docker-for-windows/install/</a></p>
                  <p>如果不是 Windows10 64 位系统，则可以下载 Docker Toolbox：<a href="https://docs.docker.com/toolbox/toolbox_install_windows/" target="_blank" rel="noopener">https://docs.docker.com/toolbox/toolbox_install_windows/</a>。</p>
                  <p>安装包下载之后直接双击安装即可，安装详细过程可以参考文档说明，安装完成之后，进入命令行。</p>
                  <p>运行 Docker 命令测试：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">docker</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行结果如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/db0eb.jpg" alt=""></p>
                  <p>如果出现类似上述输出就证明 Docker 安装成功了。</p>
                  <h2 id="Linux-下的安装"><a href="#Linux-下的安装" class="headerlink" title="Linux 下的安装"></a>Linux 下的安装</h2>
                  <p>详细的分步骤的安装说明可以参见官方文档：<a href="https://docs.docker.com/engine/installation/linux/ubuntu/" target="_blank" rel="noopener">https://docs.docker.com/engine/installation/linux/ubuntu/</a>。</p>
                  <p>在官方文档中详细说明了不同 Linux 系统的安装方法，安装流程根据文档一步步执行即可安装成功。</p>
                  <p>但是为了使得安装更加方便，Docker 官方还提供了一键安装脚本，使用它会使得安装更加便捷，不用再去一步步执行命令安装了，在此介绍一下一键脚本安装方式。</p>
                  <p>首先是 Docker 官方提供的安装脚本，相比其他脚本，官方提供的一定更靠谱，安装命令如下：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">curl -sSL http<span class="variable">s:</span>//<span class="built_in">get</span>.docker.<span class="keyword">com</span>/ | <span class="keyword">sh</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>只要执行如上一条命令，等待一会儿 Docker 便会安装完成，非常方便。</p>
                  <p>但是官方脚本安装有一个缺点，那就是慢，也可能下载超时，所以为了加快下载速度，我们可以使用国内的镜像来安装，所以在这里还有阿里云和 DaoCloud 的安装脚本。</p>
                  <p>阿里云安装脚本：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">curl -sSL http://acs-public-mirror.oss-<span class="keyword">cn</span>-hangzhou.aliyuncs.<span class="keyword">com</span>/docker-engine/internet | <span class="keyword">sh</span> -</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>DaoCloud 安装脚本：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">curl -sSL http<span class="variable">s:</span>//<span class="built_in">get</span>.daocloud.io/docker | <span class="keyword">sh</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>两个脚本可以任选其一，速度都非常不错。</p>
                  <p>等待脚本执行完毕之后，就可以使用 Docker 相关命令了，如运行测试 Hello World 镜像：</p>
                  <figure class="highlight dockerfile">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker <span class="keyword">run</span><span class="bash"> hello-world</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行结果：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">Unable <span class="keyword">to</span> <span class="keyword">find</span> image <span class="string">'hello-world:latest'</span> locally</span><br><span class="line">lates<span class="variable">t:</span> Pulling from library/hello-world</span><br><span class="line"><span class="number">78445</span>dd45222: Pull <span class="built_in">complete</span></span><br><span class="line">Diges<span class="variable">t:</span> <span class="built_in">sha256</span>:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7</span><br><span class="line">Statu<span class="variable">s:</span> Downloaded newer image <span class="keyword">for</span> hello-world:latest</span><br><span class="line">Hello from Docker!</span><br><span class="line">This message shows that your installation appears <span class="keyword">to</span> <span class="keyword">be</span> working correctly.</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果出现上文类似提示内容则证明 Docker 可以正常使用了。</p>
                  <h2 id="Mac-下的安装"><a href="#Mac-下的安装" class="headerlink" title="Mac 下的安装"></a>Mac 下的安装</h2>
                  <p>Mac 平台同样有两种选择，Docker for Mac 和 Docker Toolbox。</p>
                  <p>Docker for Mac 要求系统为 OS X EI Captain 10.11 或更新，至少 4GB 内存，如果你的系统满足此要求，则强烈建议安装 Docker for Mac。</p>
                  <p>可以使用 HomeBrew 安装，安装命令如下：</p>
                  <figure class="highlight mipsasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span>cask <span class="keyword">install </span>docker</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>另外也可以手动下载安装包安装，安装包下载地址为：<a href="https://download.docker.com/mac/stable/Docker.dmg" target="_blank" rel="noopener">https://download.docker.com/mac/stable/Docker.dmg</a></p>
                  <p>下载完成之后直接双击安装包，然后将程序拖动到应用程序中即可。</p>
                  <p>点击程序图标运行 Docker，会发现在菜单栏中出现了 Docker 的图标，如图中的第三个小鲸鱼图标：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/k3gbn.jpg" alt=""></p>
                  <p>点击图标展开菜单之后，再点击 Start 按钮即可启动 Docker，启动成功便会提示 Docker is running，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/oy367.jpg" alt=""></p>
                  <p>随后我们就可以在命令行下使用 Docker 命令了。</p>
                  <p>可以使用如下命令测试运行：</p>
                  <figure class="highlight dockerfile">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo docker <span class="keyword">run</span><span class="bash"> hello-world</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行结果如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/pti3v.jpg" alt=""></p>
                  <p>如果出现类似输出则证明 Docker 已经成功安装。</p>
                  <p>如果系统不满足要求，可以下载 Docker Toolbox，其安装说明为：<a href="https://docs.docker.com/toolbox/overview/" target="_blank" rel="noopener">https://docs.docker.com/toolbox/overview/</a>。</p>
                  <p>关于 Docker for Mac 和 Docker Toolbox 的区别，可以参见：<a href="https://docs.docker.com/docker-for-mac/docker-toolbox/" target="_blank" rel="noopener">https://docs.docker.com/docker-for-mac/docker-toolbox/</a>。</p>
                  <h2 id="镜像加速"><a href="#镜像加速" class="headerlink" title="镜像加速"></a>镜像加速</h2>
                  <p>安装好 Docker 之后，在运行测试命令时，我们会发现它首先会下载一个 Hello World 的镜像，然后将其运行，但是下载速度有时候会非常慢，这是因为它默认还是从国外的 Docker Hub 下载的，所以为了提高镜像的下载速度，我们还可以使用国内镜像来加速下载，所以这就有了 Docker 加速器一说。</p>
                  <p>推荐的 Docker 加速器有 DaoCloud 和阿里云。</p>
                  <p>DaoCloud：<a href="https://www.daocloud.io/mirror" target="_blank" rel="noopener">https://www.daocloud.io/mirror</a></p>
                  <p>阿里云：<a href="https://cr.console.aliyun.com/#/accelerator" target="_blank" rel="noopener">https://cr.console.aliyun.com/#/accelerator</a></p>
                  <p>不同平台的镜像加速方法配置可以参考 DaoCloud 的官方文档：<a href="http://guide.daocloud.io/dcs/daocloud-9153151.html" target="_blank" rel="noopener">http://guide.daocloud.io/dcs/daocloud-9153151.html</a>。</p>
                  <p>配置完成之后，可以发现镜像的下载速度会快非常多。</p>
                  <p>以上便是 Docker 的安装方式说明。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 11:41:41" itemprop="dateCreated datePublished" datetime="2021-10-03T11:41:41+08:00">2021-10-03</time>
                </span>
                <span id="/31054.html" class="post-meta-item leancloud_visitors" data-flag-title="Docker 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>3k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>3 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31053.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31053.html" class="post-title-link" itemprop="url">mitmproxy 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>mitmproxy 是一个支持 HTTP 和 HTTPS 的抓包程序，类似 Fiddler、Charles 的功能，只不过它是一个控制台的形式操作。</p>
                  <p>同时 mitmproxy 还有两个关联组件，一个是 mitmdump，它是 mitmproxy 的命令行接口，利用它我们可以对接 Python 脚本，用 Python 实现监听后的处理。另一个是 mitmweb，它是一个 Web 程序，通过它我们可以清楚地观察到 mitmproxy 捕获的请求。</p>
                  <p>本节我们来了解一下 mitmproxy、mitmdump、mitmweb 的安装方式。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/mitmproxy/mitmproxy" target="_blank" rel="noopener">https://github.com/mitmproxy/mitmproxy</a></li>
                    <li>官方网站：<a href="https://mitmproxy.org" target="_blank" rel="noopener">https://mitmproxy.org</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/mitmproxy" target="_blank" rel="noopener">https://pypi.python.org/pypi/mitmproxy</a></li>
                    <li>官方文档：<a href="http://docs.mitmproxy.org" target="_blank" rel="noopener">http://docs.mitmproxy.org</a></li>
                    <li>mitmdump 脚本：<a href="http://docs.mitmproxy.org/en/stable/scripting/overview.html" target="_blank" rel="noopener">http://docs.mitmproxy.org/en/stable/scripting/overview.html</a></li>
                    <li>下载地址：<a href="https://github.com/mitmproxy/mitmproxy/releases" target="_blank" rel="noopener">https://github.com/mitmproxy/mitmproxy/releases</a></li>
                    <li>DockerHub：<a href="https://hub.docker.com/r/mitmproxy/mitmproxy" target="_blank" rel="noopener">https://hub.docker.com/r/mitmproxy/mitmproxy</a></li>
                  </ul>
                  <h2 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h2>
                  <p>最简单的安装方式还是使用 pip，直接执行如下命令即可安装：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> mitmproxy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这是最简单和通用的安装方式，执行完毕之后即可完成 mitmproxy 的安装，另外还安装了 mitmdump、mitmweb 两个组件，如果不想用此种方式安装也可以选择下文列出的专门针对各个平台的安装方式或者 Docker 安装方式。</p>
                  <h2 id="Windows-下的安装"><a href="#Windows-下的安装" class="headerlink" title="Windows 下的安装"></a>Windows 下的安装</h2>
                  <p>可以到 <a href="https://mitmproxy.org/" target="_blank" rel="noopener">https://mitmproxy.org/</a> 获取安装包，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/qk830.png" alt=""></p>
                  <p>下载之后直接双击安装包即可安装。</p>
                  <p>注意在 Windows 上不支持 mitmproxy 的控制台接口，但是可以使用 mitmdump 和 mitmweb。</p>
                  <h2 id="Linux-下的安装"><a href="#Linux-下的安装" class="headerlink" title="Linux 下的安装"></a>Linux 下的安装</h2>
                  <p>Linux 可以下载编译好的二进制包，此发行包一般是最新版本，它包含了最新版本的 mitmproxy 和内置的 Python3 环境还有最新的 OpenSSL 环境。</p>
                  <p>如果你的环境里没有 Python3 和 OpenSSL 环境，建议使用此种方式安装，如图所示，下载安装包即可：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/v5ynj.png" alt=""></p>
                  <p>下载之后需要解压然后将其配置到环境变量。</p>
                  <figure class="highlight properties">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attr">tar</span> <span class="string">-zxvf mitmproxy-*-linux.tar.gz</span></span><br><span class="line"><span class="attr">sudo</span> <span class="string">mv mitmproxy mitmdump mitmweb /usr/bin</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样就可以将三个可执行文件移动到了 /usr/bin 目录，而一般 /usr/bin 目录都已经配置在了环境变量下，所以接下来我们就可以直接调用这三个工具了。</p>
                  <h2 id="Mac-下的安装"><a href="#Mac-下的安装" class="headerlink" title="Mac 下的安装"></a>Mac 下的安装</h2>
                  <p>Mac 的安装非常简单，使用 HomeBrew 即可，命令如下：</p>
                  <figure class="highlight mipsasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span><span class="keyword">install </span>mitmproxy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>执行命令后即可完成 mitmproxy 的安装。</p>
                  <h2 id="Docker-安装"><a href="#Docker-安装" class="headerlink" title="Docker 安装"></a>Docker 安装</h2>
                  <p>mitmproxy 也支持 Docker，其 Docker Hub 的地址为：<a href="https://hub.docker.com/r/mitmproxy/mitmproxy/" target="_blank" rel="noopener">https://hub.docker.com/r/mitmproxy/mitmproxy/</a></p>
                  <p>Docker 下 mitmproxy 的安装命令为：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run --rm -it -p <span class="number">8080</span>:<span class="number">8080</span> mitmproxy/mitmproxy mitmdump</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样就在 8080 端口上启动了 mitmproxy 和 mitmdump。</p>
                  <p>如果想要获取 CA 证书，可以选择挂载磁盘选项，命令如下：</p>
                  <figure class="highlight jboss-cli">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run <span class="params">--rm</span> -it -v ~<span class="string">/.mitmproxy</span>:<span class="string">/home/mitmproxy/.mitmproxy</span> -p 8080<span class="function">:8080</span> mitmproxy/mitmproxy mitmdump</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样可以在 ~/.mitmproxy 目录找到 CA 证书。</p>
                  <p>另外还可以在 8081 端口上启动 mitmweb，命令如下：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run --rm -it -p <span class="number">8080</span>:<span class="number">8080</span> -p <span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>:<span class="number">8081</span>:<span class="number">8081</span> mitmproxy/mitmproxy mitmweb</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>更多启动方式可以参考 Docker Hub 的安装说明。</p>
                  <h2 id="证书配置"><a href="#证书配置" class="headerlink" title="证书配置"></a>证书配置</h2>
                  <p>对于 mitmproxy 来说，如果想要截获 HTTPS 请求，我们就需要设置证书，mitmproxy 在安装后会提供一套 CA 证书，只要客户端信任了 mitmproxy 提供的证书，我们就可以通过 mitmproxy 获取 HTTPS 请求的具体内容，否则 mitmproxy 是无法解析 HTTPS 请求的。</p>
                  <p>首先运行一下命令产生 CA 证书，启动 mitmdump 即可：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">mitmdump</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样即可启动 mitmdump，接下来我们就可以在用户目录下的 .mitmproxy 目录里面找到 CA 证书，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/rzz05.jpg" alt=""></p>
                  <p>证书一共五个，下面是对这五个证书的说明：</p>
                  <div class="table-container">
                    <table>
                      <thead>
                        <tr>
                          <th>名称</th>
                          <th>描述</th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr>
                          <td>mitmproxy-ca.pem</td>
                          <td>PEM 格式的证书私钥</td>
                        </tr>
                        <tr>
                          <td>mitmproxy-ca-cert.pem</td>
                          <td>PEM 格式证书，适用于大多数非 Windows 平台</td>
                        </tr>
                        <tr>
                          <td>mitmproxy-ca-cert.p12</td>
                          <td>PKCS12 格式的证书，适用于 Windows 平台</td>
                        </tr>
                        <tr>
                          <td>mitmproxy-ca-cert.cer</td>
                          <td>与 mitmproxy-ca-cert.pem 相同，只是改变了后缀，适用于部分 Android 平台</td>
                        </tr>
                        <tr>
                          <td>mitmproxy-dhparam.pem</td>
                          <td>PEM 格式的秘钥文件，用于增强 SSL 安全性</td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                  <p>下面我们介绍一下 Windows、Mac、iOS、Android 平台下的证书配置过程。</p>
                  <h2 id="Windows"><a href="#Windows" class="headerlink" title="Windows"></a>Windows</h2>
                  <p>双击 mitmproxy-ca.p12，就会出现导入证书的引导页，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/g30hl.jpg" alt=""></p>
                  <p>直接点击下一步即可，接下来会出现密码设置提示，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/hpci3.jpg" alt=""></p>
                  <p>不需要设置密码，直接点击下一步即可。</p>
                  <p>接下来需要选择证书的存储区域，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/gczee.jpg" alt=""></p>
                  <p>点击第二个选项“将所有证书放入下列存储”，然后点击浏览，再选择证书存储位置为“受信任的根证书颁发机构”，确定，点击下一步。</p>
                  <p>最后如果有安全警告均点击“是”即可，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/3qej6.jpg" alt=""></p>
                  <p>这样就配置完成 Windows 下信任 CA 证书了。</p>
                  <h3 id="Mac"><a href="#Mac" class="headerlink" title="Mac"></a>Mac</h3>
                  <p>Mac 下双击 mitmproxy-ca-cert.pem 即可弹出钥匙串管理页面，然后找到 mitmproxy 证书，点击打开其设置选项，选择始终信任即可，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/nnvdn.jpg" alt=""></p>
                  <p>这样就配置完成 Mac 下信任 CA 证书了。</p>
                  <h3 id="iOS"><a href="#iOS" class="headerlink" title="iOS"></a>iOS</h3>
                  <p>将 mitmproxy-ca-cert.pem 文件发送到 iPhone 上，推荐使用邮件的方式发送，iPhone 上可以直接点击附件并识别安装，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/9fj4a.jpg" alt=""></p>
                  <p>点击之后会跳到安装描述文件的页面，点击右上角的安装按钮即可安装，此处会有警告提示，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/f0j8j.jpg" alt=""></p>
                  <p>继续点击右上角的安装即可，安装成功之后会有已安装的提示，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/sm8sl.jpg" alt=""></p>
                  <p>如果你的 iOS 版本是 10.3 以下的话，此处信任 CA 证书的流程就已经完成了。</p>
                  <p>如果你的 iOS 版本是 10.3 及以上，还需要在设置-&gt;通用-&gt;关于本机-&gt;证书信任设置将证书添加完全信任，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/rys5a.jpg" alt=""></p>
                  <p>在这里将 mitmproxy 的完全信任开关打开即可。</p>
                  <p>这样 iOS 上配置信任 CA 证书的流程就结束了。</p>
                  <h3 id="Android"><a href="#Android" class="headerlink" title="Android"></a>Android</h3>
                  <p>Android 手机同样需要将证书 mitmproxy-ca-cert.pem 文件发送到手机上，例如直接拷贝文件。</p>
                  <p>接下来点击证书便会出现一个提示窗口，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/1k27r.jpg" alt=""></p>
                  <p>这时输入证书的名称，然后点击确定即可完成安装。</p>
                  <h2 id="结语"><a href="#结语" class="headerlink" title="结语"></a>结语</h2>
                  <p>本节我们了解了 mitmproxy、mitmdump、mitmweb 的安装方式。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 10:42:41" itemprop="dateCreated datePublished" datetime="2021-10-03T10:42:41+08:00">2021-10-03</time>
                </span>
                <span id="/31053.html" class="post-meta-item leancloud_visitors" data-flag-title="mitmproxy 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>3k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>3 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31052.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31052.html" class="post-title-link" itemprop="url">ScrapydAPI 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>安装好了 Scrapyd 之后，我们可以直接请求它提供的 API 即可获取当前主机的 Scrapy 任务运行状况。</p>
                  <p>如某台主机的 IP 为 192.168.1.1，则可以直接运行如下命令获取当前主机的所有 Scrapy 项目：</p>
                  <figure class="highlight groovy">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">curl <span class="string">http:</span><span class="comment">//localhost:6800/listprojects.json</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行结果：</p>
                  <figure class="highlight json">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">&#123;<span class="attr">"status"</span>: <span class="string">"ok"</span>, <span class="attr">"projects"</span>: [<span class="string">"myproject"</span>, <span class="string">"otherproject"</span>]&#125;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>返回结果是 JSON 字符串，通过解析这个字符串我们便可以得到当前主机所有项目。</p>
                  <p>但是用这种方式来获取任务状态还是有点繁琐，所以 ScrapydAPI 就为它做了一层封装，下面我们来看下它的安装方式。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://pypi.python.org/pypi/python-scrapyd-api/" target="_blank" rel="noopener">https://pypi.python.org/pypi/python-scrapyd-api/</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/python-scrapyd-api" target="_blank" rel="noopener">https://pypi.python.org/pypi/python-scrapyd-api</a></li>
                    <li>官方文档：<a href="http://python-scrapyd-api.readthedocs.io/en/latest/usage.html" target="_blank" rel="noopener">http://python-scrapyd-api.readthedocs.io/en/latest/usage.html</a></li>
                  </ul>
                  <h2 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h2>
                  <p>推荐使用 Pip 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip <span class="keyword">install</span> python-scrapyd-api</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>安装完成之后便可以使用 Python 来获取主机状态了，所以如上的操作便可以用 Python 代码实现：</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">from</span> scrapyd_api <span class="keyword">import</span> ScrapydAPI</span><br><span class="line">scrapyd = ScrapydAPI(<span class="string">'http://localhost:6800'</span>)</span><br><span class="line">print(scrapyd.list_projects())</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行结果：</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">[<span class="string">"myproject"</span>, <span class="string">"otherproject"</span>]</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样我们便可以用 Python 直接来获取各个主机上 Scrapy 任务的运行状态了。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 10:41:41" itemprop="dateCreated datePublished" datetime="2021-10-03T10:41:41+08:00">2021-10-03</time>
                </span>
                <span id="/31052.html" class="post-meta-item leancloud_visitors" data-flag-title="ScrapydAPI 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>769</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31051.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31051.html" class="post-title-link" itemprop="url">Gerapy 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Gerapy 是一个 Scrapy 分布式管理模块，本节来介绍一下 Gerapy 的安装方式。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/Gerapy" target="_blank" rel="noopener">https://github.com/Gerapy</a></li>
                    <li>文档：<a href="https://docs.gerapy.com" target="_blank" rel="noopener">https://docs.gerapy.com</a></li>
                  </ul>
                  <h2 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h2>
                  <p>推荐使用 pip 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> gerapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="测试安装"><a href="#测试安装" class="headerlink" title="测试安装"></a>测试安装</h2>
                  <p>安装完成之后，可以在 Python 命令行下测试。</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span><span class="keyword">import</span> gerapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果没有错误报出，则证明库已经安装好了。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 10:40:41" itemprop="dateCreated datePublished" datetime="2021-10-03T10:40:41+08:00">2021-10-03</time>
                </span>
                <span id="/31051.html" class="post-meta-item leancloud_visitors" data-flag-title="Gerapy 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>223</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31050.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31050.html" class="post-title-link" itemprop="url">Scrapyd-Client 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>在将 Scrapy 代码部署到远程 Scrapyd 的时候，其第一步就是要将代码打包为 Egg 文件，其次需要将 Egg 文件上传到远程主机，这个过程如果我们用程序来实现是完全可以的，但是我们并不需要做这些工作，因为 Scrapyd-Client 已经为我们实现了这些功能。</p>
                  <p>下面我们就来来一下 Scrapyd-Client 的安装过程。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/scrapy/scrapyd-client" target="_blank" rel="noopener">https://github.com/scrapy/scrapyd-client</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/scrapyd-client" target="_blank" rel="noopener">https://pypi.python.org/pypi/scrapyd-client</a></li>
                    <li>使用说明：<a href="https://github.com/scrapy/scrapyd-client#scrapyd-deploy" target="_blank" rel="noopener">https://github.com/scrapy/scrapyd-client#scrapyd-deploy</a></li>
                  </ul>
                  <h2 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h2>
                  <p>推荐使用 pip 安装，命令如下：</p>
                  <figure class="highlight sql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> scrapyd-<span class="keyword">client</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>安装成功后会有一个可用命令，叫做 scrapyd-deploy，即部署命令。</p>
                  <p>我们可以输入如下测试命令测试 Scrapyd-Client 是否安装成功：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">scrapyd-deploy -h</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果出现如图类似输出则证明 Scrapyd-Client 已经成功安装:</p>
                  <p><img src="https://qiniu.cuiqingcai.com/olrt2.jpg" alt=""></p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 10:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T10:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31050.html" class="post-meta-item leancloud_visitors" data-flag-title="Scrapyd-Client 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>488</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31049.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31049.html" class="post-title-link" itemprop="url">Scrapyd 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Scrapyd 是一个用于部署和运行 Scrapy 项目的工具。有了它，你可以将写好的 Scrapy 项目上传到云主机并通过 API 来控制它的运行。</p>
                  <p>既然是 Scrapy 项目部署，所以基本上都使用 Linux 主机，所以本节的安装是针对于 Linux 主机的。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/scrapy/scrapyd" target="_blank" rel="noopener">https://github.com/scrapy/scrapyd</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/scrapyd" target="_blank" rel="noopener">https://pypi.python.org/pypi/scrapyd</a></li>
                    <li>官方文档：<a href="https://scrapyd.readthedocs.io" target="_blank" rel="noopener">https://scrapyd.readthedocs.io</a></li>
                  </ul>
                  <h2 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h2>
                  <p>推荐使用 pip 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> scrapyd</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2>
                  <p>安装完毕之后需要新建一个配置文件 /etc/scrapyd/scrapyd.conf，Scrapyd 在运行的时候会读取此配置文件。</p>
                  <p>在 Scrapyd 1.2 版本之后不会自动创建该文件，需要我们自行添加。</p>
                  <p>执行命令新建文件：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo <span class="built_in">mkdir</span> /etc/scrapyd</span><br><span class="line">sudo <span class="keyword">vi</span> /etc/scrapyd/scrapyd.<span class="keyword">conf</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>写入如下内容：</p>
                  <figure class="highlight ini">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="section">[scrapyd]</span></span><br><span class="line"><span class="attr">eggs_dir</span>    = eggs</span><br><span class="line"><span class="attr">logs_dir</span>    = logs</span><br><span class="line"><span class="attr">items_dir</span>   =</span><br><span class="line"><span class="attr">jobs_to_keep</span> = <span class="number">5</span></span><br><span class="line"><span class="attr">dbs_dir</span>     = dbs</span><br><span class="line"><span class="attr">max_proc</span>    = <span class="number">0</span></span><br><span class="line"><span class="attr">max_proc_per_cpu</span> = <span class="number">10</span></span><br><span class="line"><span class="attr">finished_to_keep</span> = <span class="number">100</span></span><br><span class="line"><span class="attr">poll_interval</span> = <span class="number">5.0</span></span><br><span class="line"><span class="attr">bind_address</span> = <span class="number">0.0</span>.<span class="number">0.0</span></span><br><span class="line"><span class="attr">http_port</span>   = <span class="number">6800</span></span><br><span class="line"><span class="attr">debug</span>       = <span class="literal">off</span></span><br><span class="line"><span class="attr">runner</span>      = scrapyd.runner</span><br><span class="line"><span class="attr">application</span> = scrapyd.app.application</span><br><span class="line"><span class="attr">launcher</span>    = scrapyd.launcher.Launcher</span><br><span class="line"><span class="attr">webroot</span>     = scrapyd.website.Root</span><br><span class="line"></span><br><span class="line"><span class="section">[services]</span></span><br><span class="line"><span class="attr">schedule.json</span>     = scrapyd.webservice.Schedule</span><br><span class="line"><span class="attr">cancel.json</span>       = scrapyd.webservice.Cancel</span><br><span class="line"><span class="attr">addversion.json</span>   = scrapyd.webservice.AddVersion</span><br><span class="line"><span class="attr">listprojects.json</span> = scrapyd.webservice.ListProjects</span><br><span class="line"><span class="attr">listversions.json</span> = scrapyd.webservice.ListVersions</span><br><span class="line"><span class="attr">listspiders.json</span>  = scrapyd.webservice.ListSpiders</span><br><span class="line"><span class="attr">delproject.json</span>   = scrapyd.webservice.DeleteProject</span><br><span class="line"><span class="attr">delversion.json</span>   = scrapyd.webservice.DeleteVersion</span><br><span class="line"><span class="attr">listjobs.json</span>     = scrapyd.webservice.ListJobs</span><br><span class="line"><span class="attr">daemonstatus.json</span> = scrapyd.webservice.DaemonStatus</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>配置文件的内容可以参见官方文档：<a href="https://scrapyd.readthedocs.io/en/stable/config.html#example-configuration-file" target="_blank" rel="noopener">https://scrapyd.readthedocs.io/en/stable/config.html#example-configuration-file</a>，在这里的配置文件有所修改，其中之一是 max_proc_per_cpu 官方默认为 4，即一台主机每个 CPU 最多运行 4 个 Scrapy Job，在此提高为 10，另外一个是 bind_address，默认为本地 127.0.0.1，在此修改为 0.0.0.0，以使外网可以访问。</p>
                  <h2 id="后台运行"><a href="#后台运行" class="headerlink" title="后台运行"></a>后台运行</h2>
                  <p>由于 Scrapyd 是一个纯 Python 项目，在这里可以直接调用 scrapyd 来运行，为了使程序一直在后台运行，Linux 和 Mac 可以使用如下命令：</p>
                  <figure class="highlight 1c">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">(scrapyd &gt; /dev/<span class="literal">null</span> <span class="meta">&amp;)</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样 Scrapyd 就会在后台持续运行了，控制台输出直接忽略，当然如果想记录输出日志可以修改输出目标，如：</p>
                  <figure class="highlight clojure">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">(<span class="name">scrapyd</span> &gt; ~/scrapyd.log &amp;)</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>则会输出 Scrapyd 运行输出到 ~/scrapyd.log 文件中。</p>
                  <p>运行之后便可以在浏览器的 6800 访问 WebUI 了，可以简略看到当前 Scrapyd 的运行 Job、Log 等内容，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/krddi.png" alt=""></p>
                  <p>当然运行 Scrapyd 更佳的方式是使用 Supervisor 守护进程运行，如果感兴趣可以参考：<a href="http://supervisord.org/" target="_blank" rel="noopener">http://supervisord.org/</a>。</p>
                  <h2 id="访问认证"><a href="#访问认证" class="headerlink" title="访问认证"></a>访问认证</h2>
                  <p>限制配置完成之后 Scrapyd 和它的接口都是可以公开访问的，如果要想配置访问认证的话可以借助于 Nginx 做反向代理，在这里需要先安装 Nginx 服务器。</p>
                  <p>在此以 Ubuntu 为例进行说明，安装命令如下：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="builtin-name">get</span> install nginx</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后修改 Nginx 的配置文件 nginx.conf，增加如下配置：</p>
                  <figure class="highlight nginx">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="section">http</span> &#123;</span><br><span class="line">    <span class="section">server</span> &#123;</span><br><span class="line">        <span class="attribute">listen</span> <span class="number">6801</span>;</span><br><span class="line">        <span class="attribute">location</span> / &#123;</span><br><span class="line">            <span class="attribute">proxy_pass</span>    http://127.0.0.1:6800/;</span><br><span class="line">            <span class="attribute">auth_basic</span>    <span class="string">"Restricted"</span>;</span><br><span class="line">            <span class="attribute">auth_basic_user_file</span>    /etc/nginx/conf.d/.htpasswd;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>在这里使用的用户名密码配置放置在 /etc/nginx/conf.d 目录，我们需要使用 htpasswd 命令创建，例如创建一个用户名为 admin 的文件，命令如下：</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">htpasswd</span> <span class="selector-tag">-c</span> <span class="selector-class">.htpasswd</span> <span class="selector-tag">admin</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>接下就会提示我们输入密码，输入两次之后，就会生成密码文件，查看一下内容：</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">cat</span> <span class="selector-class">.htpasswd</span></span><br><span class="line"><span class="selector-tag">admin</span><span class="selector-pseudo">:5ZBxQr0rCqwbc</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>配置完成之后我们重启一下 Nginx 服务，运行如下命令：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">sudo nginx -s reload</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样就成功配置了 Scrapyd 的访问认证了。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 09:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T09:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31049.html" class="post-meta-item leancloud_visitors" data-flag-title="Scrapyd 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>2.4k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>2 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31048.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31048.html" class="post-title-link" itemprop="url">pyspider 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>PySpider 是国人 binux 编写的强大的网络爬虫框架，它带有强大的 WebUI、脚本编辑器、任务监控器、项目管理器以及结果处理器，同时它支持多种数据库后端、多种消息队列，另外它还支持 JavaScript 渲染页面的爬取，使用起来非常方便，本节介绍一下它的安装过程。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>官方文档：<a href="http://docs.pyspider.org/" target="_blank" rel="noopener">http://docs.pyspider.org/</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/pyspider" target="_blank" rel="noopener">https://pypi.python.org/pypi/pyspider</a></li>
                    <li>GitHub：<a href="https://github.com/binux/pyspider" target="_blank" rel="noopener">https://github.com/binux/pyspider</a></li>
                    <li>官方教程：<a href="http://docs.pyspider.org/en/latest/tutorial" target="_blank" rel="noopener">http://docs.pyspider.org/en/latest/tutorial</a></li>
                    <li>在线实例：<a href="http://demo.pyspider.org" target="_blank" rel="noopener">http://demo.pyspider.org</a></li>
                  </ul>
                  <h2 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h2>
                  <p>PySpider 是支持 JavaScript 渲染的，而这个过程是依赖于 PhantomJS 的，所以还需要安装 PhantomJS，所以在安装之前请安装好 PhantomJS，参考 <a href="https://setup.scrape.center/phantomjs。" target="_blank" rel="noopener">https://setup.scrape.center/phantomjs。</a></p>
                  <h2 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h2>
                  <p>推荐使用 pip 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> pyspider</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>命令执行完毕即可完成安装。</p>
                  <h2 id="常见错误"><a href="#常见错误" class="headerlink" title="常见错误"></a>常见错误</h2>
                  <p>Windows 下可能会出现这样的错误提示：Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-vXo1W3/pycurl</p>
                  <p>这个是 PyCurl 安装错误，一般会出现在 Windows 下，需要安装 PyCurl 库，下载链接为：<a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycurl" target="_blank" rel="noopener">http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycurl</a>，找到对应 Python 版本然后下载相应的 Wheel 文件。</p>
                  <p>如 Windows 64 位，Python3.6 则下载 pycurl‑7.43.0‑cp36‑cp36m‑win_amd64.whl，随后用 Pip 安装即可，命令如下：</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">pip3</span> <span class="selector-tag">install</span> <span class="selector-tag">pycurl</span>‑7<span class="selector-class">.43</span><span class="selector-class">.0</span>‑<span class="selector-tag">cp36</span>‑<span class="selector-tag">cp36m</span>‑<span class="selector-tag">win_amd64</span><span class="selector-class">.whl</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>Linux 下如果遇到 PyCurl 的错误可以参考本文：<a href="https://imlonghao.com/19.html" target="_blank" rel="noopener">https://imlonghao.com/19.html</a></p>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>安装完成之后，可以直接在命令行下启动 PySpider：</p>
                  <figure class="highlight ada">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pyspider <span class="keyword">all</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>控制台会有类似如下输出，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/sidd0.jpg" alt=""></p>
                  <p>这时 PySpider 的 Web 服务就会在本地 5000 端口运行，直接在浏览器打开：<a href="http://localhost:5000/" target="_blank" rel="noopener">http://localhost:5000/</a> 即可进入 PySpider 的 WebUI 管理页面，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/1zk1r.png" alt=""></p>
                  <p>如果出现类似页面那证明 PySpider 已经安装成功了。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 08:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T08:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31048.html" class="post-meta-item leancloud_visitors" data-flag-title="pyspider 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>1.1k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31047.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31047.html" class="post-title-link" itemprop="url">Scrapy 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Scrapy 是一个十分强大的爬虫框架，依赖的库比较多，至少需要依赖库有 Twisted，lxml，pyOpenSSL。而在不同平台环境又各不相同，所以在安装之前最好确保把一些基本库安装好，尤其是 Windows。本节介绍一下 Scrapy 在不同平台的安装方法。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://scrapy.org" target="_blank" rel="noopener">https://scrapy.org</a></li>
                    <li>官方文档：<a href="https://docs.scrapy.org" target="_blank" rel="noopener">https://docs.scrapy.org</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/Scrapy" target="_blank" rel="noopener">https://pypi.python.org/pypi/Scrapy</a></li>
                    <li>GitHub：<a href="https://github.com/scrapy/scrapy" target="_blank" rel="noopener">https://github.com/scrapy/scrapy</a></li>
                    <li>中文文档：<a href="http://scrapy-chs.readthedocs.io" target="_blank" rel="noopener">http://scrapy-chs.readthedocs.io</a></li>
                  </ul>
                  <h2 id="Anaconda-安装"><a href="#Anaconda-安装" class="headerlink" title="Anaconda 安装"></a>Anaconda 安装</h2>
                  <p>这种方法是一种比较简单的安装 Scrapy 的方法（尤其是对 Windows 来说），如果你的 Python 是使用 Anaconda 安装的，或者还没有安装 Python 的话，可以使用该方法安装，简单省力，当然如果你的 Python 不是通过 Anaconda 安装的，可以继续查看下文中各平台直接安装方法。</p>
                  <p>Anaconda 的安装方式可以查看 <a href="https://setup.scrape.center/python，在此不再赘述。" target="_blank" rel="noopener">https://setup.scrape.center/python，在此不再赘述。</a></p>
                  <p>如果已经安装好了 Anaconda，那么可以通过 conda 命令安装 Scrapy，安装命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">conda <span class="keyword">install</span> Scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行之后便可以完成 Scrapy 的安装。</p>
                  <h2 id="Windows-下的安装"><a href="#Windows-下的安装" class="headerlink" title="Windows 下的安装"></a>Windows 下的安装</h2>
                  <p>如果你的 Python 不是使用 Anaconda 安装的，可以参考如下方式来一步步完成 Scrapy 的安装。</p>
                  <p>首先尝试直接使用 pip3 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果安装过程一切顺利，那就可以忽略后续步骤，否则，请参阅后续步骤一点点安装。</p>
                  <h3 id="安装-lxml"><a href="#安装-lxml" class="headerlink" title="安装 lxml"></a>安装 lxml</h3>
                  <p>lxml 的安装过程请参见 <a href="https://setup.scrape.center/lxml，在此不再赘述，此库非常重要，请一定要安装成功。" target="_blank" rel="noopener">https://setup.scrape.center/lxml，在此不再赘述，此库非常重要，请一定要安装成功。</a></p>
                  <h3 id="安装-pyOpenSSL"><a href="#安装-pyOpenSSL" class="headerlink" title="安装 pyOpenSSL"></a>安装 pyOpenSSL</h3>
                  <p>官方网站下载 Wheel 文件，<a href="https://pypi.python.org/pypi/pyOpenSSL#downloads" target="_blank" rel="noopener">https://pypi.python.org/pypi/pyOpenSSL#downloads</a>，如当前最新版本名称是 pyOpenSSL-21.0.0-py2.py3-none-any.whl ，直接下载，下载后利用 pip 安装即可：</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">pip3</span> <span class="selector-tag">install</span> <span class="selector-tag">pyOpenSSL-17</span><span class="selector-class">.2</span><span class="selector-class">.0-py2</span><span class="selector-class">.py3-none-any</span><span class="selector-class">.whl</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="安装-Twisted"><a href="#安装-Twisted" class="headerlink" title="安装 Twisted"></a>安装 Twisted</h3>
                  <p>到 <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted" target="_blank" rel="noopener">http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted</a> 下载 Wheel 文件，利用 pip 安装即可。<br>如 Python 3.6 版本，Windows 64 位系统，当前最新版本为 Twisted‑20.3.0‑cp36‑cp36m‑win_amd64.whl，直接下载即可，如图所示，最新版本以网站为准。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/3u07o.png" alt=""></p>
                  <p>然后 pip 安装即可：</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">pip3</span> <span class="selector-tag">install</span> <span class="selector-tag">Twisted</span>‑17<span class="selector-class">.5</span><span class="selector-class">.0</span>‑<span class="selector-tag">cp36</span>‑<span class="selector-tag">cp36m</span>‑<span class="selector-tag">win_amd64</span><span class="selector-class">.whl</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="安装-PyWin32"><a href="#安装-PyWin32" class="headerlink" title="安装 PyWin32"></a>安装 PyWin32</h3>
                  <p>从官方网站下载对应版本的安装包即可，链接为：<a href="https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/" target="_blank" rel="noopener">https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/</a>，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/8o9us.jpg" alt=""></p>
                  <p>如 Python 3.6 版本可以选择下载 pywin32-221.win-amd64-py3.6.exe，下载完毕之后双击安装即可。</p>
                  <p>注意这里使用的是 Build 221 版本，随着时间推移，版本肯定会继续更新，最新的版本可以查看：<a href="https://sourceforge.net/projects/pywin32/files/pywin32/" target="_blank" rel="noopener">https://sourceforge.net/projects/pywin32/files/pywin32/</a>，查找最新的版本安装即可。</p>
                  <h3 id="安装-Scrapy"><a href="#安装-Scrapy" class="headerlink" title="安装 Scrapy"></a>安装 Scrapy</h3>
                  <p>安装好了以上的依赖库，最后安装 Scrapy 就非常简单了，依然使用 pip，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>等待命令结束没有报错，就证明 Scrapy 已经安装好了。</p>
                  <h2 id="Linux-下的安装"><a href="#Linux-下的安装" class="headerlink" title="Linux 下的安装"></a>Linux 下的安装</h2>
                  <p>在 Linux 上的安装方式依然分为两类平台介绍。</p>
                  <h3 id="CentOS、RedHat"><a href="#CentOS、RedHat" class="headerlink" title="CentOS、RedHat"></a>CentOS、RedHat</h3>
                  <p>首先确保一些依赖库已经安装，运行如下命令：</p>
                  <figure class="highlight gml">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo yum groupinstall -<span class="symbol">y</span> development tools</span><br><span class="line">sudo yum install -<span class="symbol">y</span> epel-release libxslt-devel libxml2-devel openssl-devel</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>最后利用 pip 安装 Scrapy 即可，运行如下命令：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> Scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="Ubuntu、Debian、Deepin"><a href="#Ubuntu、Debian、Deepin" class="headerlink" title="Ubuntu、Debian、Deepin"></a>Ubuntu、Debian、Deepin</h3>
                  <p>首先确保一些依赖库已经安装，运行如下命令：</p>
                  <figure class="highlight q">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="built_in">get</span> install build-essential python3-<span class="built_in">dev</span> libssl-<span class="built_in">dev</span> libffi-<span class="built_in">dev</span> libxml2 libxml2-<span class="built_in">dev</span> libxslt1-<span class="built_in">dev</span> zlib1g-<span class="built_in">dev</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后利用 Pip 安装 Scrapy 即可，运行如下命令：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> Scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行完毕之后即可完成 Scrapy 的安装。</p>
                  <h2 id="Mac-下的安装"><a href="#Mac-下的安装" class="headerlink" title="Mac 下的安装"></a>Mac 下的安装</h2>
                  <p>在 Mac 下首先也是进行依赖库的安装。</p>
                  <p>在 Mac 上构建 Scrapy 的依赖库需要 C 编译器以及开发头文件，它一般由 Xcode 提供，运行如下命令安装即可：</p>
                  <figure class="highlight ada">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">xcode-<span class="keyword">select</span> <span class="comment">--install</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>随后利用 Pip 安装 Scrapy 即可，运行如下命令：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> Scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行完毕之后即可完成 Scrapy 的安装。</p>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>安装之后，在命令行下输入 scrapy，如果出现类似下方的结果，就证明 Scrapy 安装成功，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/fv2xe.png" alt=""></p>
                  <h2 id="常见错误"><a href="#常见错误" class="headerlink" title="常见错误"></a>常见错误</h2>
                  <h3 id="pkg-resources-VersionConflict-six-1-5-2-usr-lib-python3-dist-packages-Requirement-parse-‘six-gt-1-6-0’"><a href="#pkg-resources-VersionConflict-six-1-5-2-usr-lib-python3-dist-packages-Requirement-parse-‘six-gt-1-6-0’" class="headerlink" title="pkg_resources.VersionConflict: (six 1.5.2 (/usr/lib/python3/dist-packages), Requirement.parse(‘six&gt;=1.6.0’))"></a>pkg_resources.VersionConflict: (six 1.5.2 (/usr/lib/python3/dist-packages), Requirement.parse(‘six&gt;=1.6.0’))</h3>
                  <p>six 包版本过低，six 包是一个提供兼容 Python2 和 Python3 的库，升级 six 包即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo pip3 <span class="keyword">install</span> -U six</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="c-cffi-backend-c-15-17-fatal-error-ffi-h-No-such-file-or-directory"><a href="#c-cffi-backend-c-15-17-fatal-error-ffi-h-No-such-file-or-directory" class="headerlink" title="c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory"></a>c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory</h3>
                  <p>这是在 Linux 下常出现的错误，缺少 Libffi 这个库。什么是 libffi？“FFI” 的全名是 Foreign Function Interface，通常指的是允许以一种语言编写的代码调用另一种语言的代码。而 Libffi 库只提供了最底层的、与架构相关的、完整的”FFI”。</p>
                  <p>安装相应的库即可。</p>
                  <p>Ubuntu、Debian：</p>
                  <figure class="highlight q">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="built_in">get</span> install build-essential libssl-<span class="built_in">dev</span> libffi-<span class="built_in">dev</span> python3-<span class="built_in">dev</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>CentOS、RedHat:</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo yum <span class="keyword">install</span> gcc libffi-devel python-devel openssl-devel</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="Command-“python-setup-py-egg-info”-failed-with-error-code-1-in-tmp-pip-build-cryptography"><a href="#Command-“python-setup-py-egg-info”-failed-with-error-code-1-in-tmp-pip-build-cryptography" class="headerlink" title="Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build/cryptography/"></a>Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build/cryptography/</h3>
                  <p>这是缺少加密的相关组件，利用 Pip 安装即可。</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> cryptography</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="ImportError-No-module-named-‘packaging’"><a href="#ImportError-No-module-named-‘packaging’" class="headerlink" title="ImportError: No module named ‘packaging’"></a>ImportError: No module named ‘packaging’</h3>
                  <p>缺少 packaging 这个包，它提供了 Python 包的核心功能，利用 Pip 安装即可。</p>
                  <h3 id="ImportError-No-module-named-‘-cffi-backend’"><a href="#ImportError-No-module-named-‘-cffi-backend’" class="headerlink" title="ImportError: No module named ‘_cffi_backend’"></a>ImportError: No module named ‘_cffi_backend’</h3>
                  <p>缺少 cffi 包，使用 Pip 安装即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> cffi</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="ImportError-No-module-named-‘pyparsing’"><a href="#ImportError-No-module-named-‘pyparsing’" class="headerlink" title="ImportError: No module named ‘pyparsing’"></a>ImportError: No module named ‘pyparsing’</h3>
                  <p>缺少 pyparsing 包，使用 Pip 安装即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> pyparsing appdirs</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 07:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T07:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31047.html" class="post-meta-item leancloud_visitors" data-flag-title="Scrapy 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>3.1k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>3 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31046.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31046.html" class="post-title-link" itemprop="url">Scrapy-Redis 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Scrapy-Redis 是 Scrapy 分布式的扩展模块，有了它我们可以方便地实现 Scrapy 分布式爬虫的搭建，本节来介绍一下 Scrapy-Redis 的安装方式。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/rmax/scrapy-redis" target="_blank" rel="noopener">https://github.com/rmax/scrapy-redis</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/scrapy-redis" target="_blank" rel="noopener">https://pypi.python.org/pypi/scrapy-redis</a></li>
                    <li>官方文档：<a href="http://scrapy-redis.readthedocs.io" target="_blank" rel="noopener">http://scrapy-redis.readthedocs.io</a></li>
                  </ul>
                  <h2 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h2>
                  <p>推荐使用 pip 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> scrapy-redis</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="Wheel-安装"><a href="#Wheel-安装" class="headerlink" title="Wheel 安装"></a>Wheel 安装</h2>
                  <p>也可以到 PyPi 下载 Wheel 文件安装：<a href="https://pypi.org/project/scrapy-redis/#downloads，如当前最新版本为" target="_blank" rel="noopener">https://pypi.org/project/scrapy-redis/#downloads，如当前最新版本为</a> 0.7.1，则可以下载 scrapy_redis-0.7.1-py2.py3-none-any.whl ，然后 pip 安装即可。</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">pip3</span> <span class="selector-tag">install</span> <span class="selector-tag">scrapy_redis-0</span><span class="selector-class">.7</span><span class="selector-class">.1-py2</span><span class="selector-class">.py3-none-any</span><span class="selector-class">.whl</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="测试安装"><a href="#测试安装" class="headerlink" title="测试安装"></a>测试安装</h2>
                  <p>安装完成之后，可以在 Python 命令行下测试。</p>
                  <figure class="highlight ruby">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt; import scrapy_redis</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果没有错误报出，则证明库已经安装好了。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 06:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T06:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31046.html" class="post-meta-item leancloud_visitors" data-flag-title="Scrapy-Redis 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>539</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31045.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31045.html" class="post-title-link" itemprop="url">redis-py 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>对于 Redis 来说，我们要使用 redis-py 库来与其交互，本节我们来介绍一下 redis-py 的安装方法。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/andymccurdy/redis-py" target="_blank" rel="noopener">https://github.com/andymccurdy/redis-py</a></li>
                    <li>官方文档：<a href="https://redis-py.readthedocs.io/" target="_blank" rel="noopener">https://redis-py.readthedocs.io/</a></li>
                  </ul>
                  <h2 id="安装方法"><a href="#安装方法" class="headerlink" title="安装方法"></a>安装方法</h2>
                  <h3 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h3>
                  <p>推荐使用 pip3 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> redis</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行完毕之后即可完成 redis-py 的安装。</p>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>为了验证库是否已经安装成功，可以在命令行下测试一下：</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span><span class="keyword">import</span> redis</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span>redis.VERSION</span><br><span class="line">(<span class="number">2</span>, <span class="number">10</span>, <span class="number">6</span>)</span><br><span class="line">&gt;&gt;&gt;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>在命令行首先输入 python3，进入命令行模式，输入如上内容，如果成功输出了其版本内容，那么证明 redis-py 成功安装。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 06:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T06:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31045.html" class="post-meta-item leancloud_visitors" data-flag-title="redis-py 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>376</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31044.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31044.html" class="post-title-link" itemprop="url">Scrapy-Splash 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Scrapy-Splash 是一个 Scrapy 中支持 JavaScript 渲染的工具，本节来介绍一下它的安装方式。</p>
                  <p>Scrapy-Splash 的安装分为两部分，一个是是 Splash 服务的安装，安装方式是通过 Docker，安装之后会启动一个 Splash 服务，我们可以通过它的接口来实现 JavaScript 页面的加载。另外一个是 ScrapySplash 的 Python 库的安装，安装之后即可在 Scrapy 中使用 Splash 服务。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/scrapy-plugins/scrapy-splash" target="_blank" rel="noopener">https://github.com/scrapy-plugins/scrapy-splash</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/scrapy-splash" target="_blank" rel="noopener">https://pypi.python.org/pypi/scrapy-splash</a></li>
                    <li>使用说明：<a href="https://github.com/scrapy-plugins/scrapy-splash#configuration" target="_blank" rel="noopener">https://github.com/scrapy-plugins/scrapy-splash#configuration</a></li>
                    <li>Splash 官方文档：<a href="http://splash.readthedocs.io" target="_blank" rel="noopener">http://splash.readthedocs.io</a></li>
                  </ul>
                  <h2 id="安装-Splash"><a href="#安装-Splash" class="headerlink" title="安装 Splash"></a>安装 Splash</h2>
                  <p>Scrapy-Splash 会使用 Splash 的 HTTP API 进行页面渲染，所以我们需要安装 Splash 来提供渲染服务，安装教程参考：<a href="https://setup.scrape.center/splash" target="_blank" rel="noopener">https://setup.scrape.center/splash</a>。</p>
                  <h2 id="Scrapy-Splash-的安装"><a href="#Scrapy-Splash-的安装" class="headerlink" title="Scrapy-Splash 的安装"></a>Scrapy-Splash 的安装</h2>
                  <p>成功安装了 Splash 之后，我们接下来再来安装一下其 Python 库，安装命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> scrapy-splash</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>命令运行完毕后就会成功安装好此库。</p>
                  <p>完毕！</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 05:49:41" itemprop="dateCreated datePublished" datetime="2021-10-03T05:49:41+08:00">2021-10-03</time>
                </span>
                <span id="/31044.html" class="post-meta-item leancloud_visitors" data-flag-title="Scrapy-Splash 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>629</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31043.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31043.html" class="post-title-link" itemprop="url">ChromeDriver 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>成功安装好了 Selenium 库，但是它是一个自动化测试工具，需要浏览器来配合它使用，那么本节我们就介绍一下 Chrome 浏览器及 ChromeDriver 驱动的配置。</p>
                  <p>首先需要下载一个 Chrome 浏览器，方法多样，在此不再赘述。</p>
                  <p>随后我们需要安装一个 ChromeDriver 才能驱动 Chrome 浏览器完成相应的操作，下面我们来介绍下怎样安装 ChromeDriver。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://sites.google.com/a/chromium.org/chromedriver" target="_blank" rel="noopener">https://sites.google.com/a/chromium.org/chromedriver</a></li>
                    <li>下载地址：<a href="https://chromedriver.storage.googleapis.com/index.html" target="_blank" rel="noopener">https://chromedriver.storage.googleapis.com/index.html</a></li>
                  </ul>
                  <h2 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h2>
                  <p>在这之前请确保已经正确安装好了 Chrome 浏览器并可以正常运行，安装过程不再赘述。</p>
                  <h2 id="查看版本"><a href="#查看版本" class="headerlink" title="查看版本"></a>查看版本</h2>
                  <p>点击 Chrome 的菜单，帮助-&gt;关于 Chrome，即可查看 Chrome 的版本号，在这里我的版本是 94.0.4606，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/xz2ag.png" alt=""></p>
                  <p>请记住 Chrome 版本号，在后面选择 ChromeDriver 版本时需要用到。</p>
                  <h2 id="下载-ChromeDriver"><a href="#下载-ChromeDriver" class="headerlink" title="下载 ChromeDriver"></a>下载 ChromeDriver</h2>
                  <p>打开 ChromeDriver 的官方网站，链接为：<a href="https://sites.google.com/chromium.org/driver/downloads" target="_blank" rel="noopener">https://sites.google.com/chromium.org/driver/downloads</a>。可以看到到目前为止最新支持的 Chrome 浏览器版本为 95，最新版本以官网为准，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/g1q0n.png" alt=""></p>
                  <p>每个版本都有相应的支持 Chrome 版本介绍，请找好自己的 Chrome 浏览器版本对应的 ChromeDriver 版本再下载，否则可能导致无法正常工作。</p>
                  <p>由于我这边的 ChromeDriver 版本是 94.0.4606，找到对应的下载列表，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/hv0bo.png" alt=""></p>
                  <p>Windows 系统就下载 win32.zip，Mac 系统 Intel 芯片下载 mac64.zip，Mac 系统 M1 芯片下载 mac64_m1.zip，Linux 系统下载 linux64.zip，下载解压之后会得到一个 ChromeDriver 的可执行文件。</p>
                  <p>另外如果上面的链接打不开的话，也可以从对应的 ChromeDriver 镜像网站下载：<a href="https://chromedriver.storage.googleapis.com/index.html" target="_blank" rel="noopener">https://chromedriver.storage.googleapis.com/index.html</a>，同样地，版本对应好即可。</p>
                  <h2 id="环境变量配置"><a href="#环境变量配置" class="headerlink" title="环境变量配置"></a>环境变量配置</h2>
                  <p>下载完成后将 ChromeDriver 的可执行文件配置到环境变量下。</p>
                  <p>在 Windows 下，建议直接将 chromedriver.exe 文件拖到 Python 的 Scripts 目录下，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/zjb0h.jpg" alt=""></p>
                  <p>也可以单独将其所在路径配置到环境变量，环境变量的配置方法请参见 Python3 的安装一节。</p>
                  <p>在 Linux、Mac 下，需要将可执行文件配置到环境变量或将文件移动到属于环境变量的目录里。</p>
                  <p>例如移动文件到 /usr/bin 目录，首先命令行进入其所在路径，然后将其移动到 /usr/bin：</p>
                  <figure class="highlight awk">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo mv chromedriver <span class="regexp">/usr/</span>bin</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>当然也可以将 ChromeDriver 配置到 $PATH，首先可以将可执行文件放到某一目录，目录可以任意选择，例如将当前可执行文件放在 /usr/local/chromedriver 目录下，接下来可以修改 ~/.profile 文件，命令如下：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="builtin-name">export</span> <span class="attribute">PATH</span>=<span class="string">"<span class="variable">$PATH</span>:/usr/local/chromedriver"</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>保存然后执行：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">source</span> ~/.<span class="keyword">profile</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>即可完成环境变量的添加。</p>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>配置完成之后，就可以在命令行下直接执行 chromedriver 命令了。</p>
                  <p>命令行下输入：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">chromedriver</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>输入控制台有类似输出，如图所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/0xyvx.png" alt=""></p>
                  <p>如果有类似输出则证明 ChromeDriver 的环境变量配置好了。</p>
                  <p>另外如果要配合代码进行测试的话，可以安装 Selenium，安装方式参考：<a href="https://setup.scrape.center/selenium" target="_blank" rel="noopener">https://setup.scrape.center/selenium</a>，安装好了之后，随后再在程序中测试，执行如下 Python 代码：</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">from</span> selenium <span class="keyword">import</span> webdriver</span><br><span class="line">browser = webdriver.Chrome()</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行之后会弹出一个空白的 Chrome 浏览器，证明所有的配置都没有问题，如果没有弹出，请检查之前的每一步的配置。</p>
                  <p>如果弹出之后闪退，则可能是 ChromeDriver 版本和 Chrome 版本不简容，请更换 ChromeDriver 版本。</p>
                  <p>如果没有问题，接下来我们就可以利用 Chrome 来做网页抓取了。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 05:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T05:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31043.html" class="post-meta-item leancloud_visitors" data-flag-title="ChromeDriver 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>1.8k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>2 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31042.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31042.html" class="post-title-link" itemprop="url">pyquery 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>pyquery 是一个强大的网页解析工具，它提供了和 jQuery 类似的语法来解析 HTML 文档，支持 CSS 选择器，使用非常方便，本节我们了解下它的安装方式。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/gawel/pyquery" target="_blank" rel="noopener">https://github.com/gawel/pyquery</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/pyquery" target="_blank" rel="noopener">https://pypi.python.org/pypi/pyquery</a></li>
                    <li>官方文档：<a href="http://pyquery.readthedocs.io" target="_blank" rel="noopener">http://pyquery.readthedocs.io</a></li>
                  </ul>
                  <h2 id="安装方法"><a href="#安装方法" class="headerlink" title="安装方法"></a>安装方法</h2>
                  <h3 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h3>
                  <p>推荐使用 pip3 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> pyquery</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>命令执行完毕之后即可完成安装。</p>
                  <h3 id="wheel-安装"><a href="#wheel-安装" class="headerlink" title="wheel 安装"></a>wheel 安装</h3>
                  <p>当然也可以到 PyPi 下载对应的 wheel 文件安装，<a href="https://pypi.python.org/pypi/pyquery/#downloads" target="_blank" rel="noopener">https://pypi.python.org/pypi/pyquery/#downloads</a>，如当前最新版本为 1.2.17，则下载的文件名称为 pyquery-1.2.17-py2.py3-none-any.whl，下载到本地再 pip3 安装即可，命令如下：</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">pip3</span> <span class="selector-tag">install</span> <span class="selector-tag">pyquery-1</span><span class="selector-class">.2</span><span class="selector-class">.17-py2</span><span class="selector-class">.py3-none-any</span><span class="selector-class">.whl</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>安装完成之后，可以在 Python 命令行下测试。</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span><span class="keyword">import</span> pyquery</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果没有错误报出，则证明库已经安装好了。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 05:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T05:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31042.html" class="post-meta-item leancloud_visitors" data-flag-title="pyquery 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>542</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31041.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31041.html" class="post-title-link" itemprop="url">PyMySQL 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>在 Python3 中如果想要将数据存储到 MySQL 中就需要借助于 PyMySQL 来操作，本节我们介绍一下 PyMySQL 的安装方式。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/PyMySQL/PyMySQL" target="_blank" rel="noopener">https://github.com/PyMySQL/PyMySQL</a></li>
                    <li>官方文档：<a href="http://pymysql.readthedocs.io/" target="_blank" rel="noopener">http://pymysql.readthedocs.io/</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/PyMySQL" target="_blank" rel="noopener">https://pypi.python.org/pypi/PyMySQL</a></li>
                  </ul>
                  <h2 id="安装方法"><a href="#安装方法" class="headerlink" title="安装方法"></a>安装方法</h2>
                  <h3 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h3>
                  <p>推荐使用 pip3 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> pymysql</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>执行完命令即可完成安装。</p>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>为了验证库是否已经安装成功，可以在命令行下测试一下：</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span><span class="keyword">import</span> pymysql</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span>pymysql.VERSION</span><br><span class="line">(<span class="number">1</span>, <span class="number">0</span>, <span class="number">2</span>, <span class="literal">None</span>)</span><br><span class="line">&gt;&gt;&gt;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>在命令行首先输入 python3，进入命令行模式，输入如上内容，如果成功输出了其版本内容，那么证明 PyMySQL 成功安装。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 04:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T04:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31041.html" class="post-meta-item leancloud_visitors" data-flag-title="PyMySQL 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>419</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/31040.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> 安装配置 <i class="label-arrow"></i>
                  </a>
                  <a href="/31040.html" class="post-title-link" itemprop="url">PyMongo 的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>在 Python 中如果想要和 MongoDB 进行交互就需要借助于 PyMongo 库，本节我们来了解一下 PyMongo 的安装方法。</p>
                  <h2 id="相关链接"><a href="#相关链接" class="headerlink" title="相关链接"></a>相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/mongodb/mongo-python-driver" target="_blank" rel="noopener">https://github.com/mongodb/mongo-python-driver</a></li>
                    <li>官方文档：<a href="https://api.mongodb.com/python/current/" target="_blank" rel="noopener">https://api.mongodb.com/python/current/</a></li>
                    <li>PyPi：<a href="https://pypi.python.org/pypi/pymongo" target="_blank" rel="noopener">https://pypi.python.org/pypi/pymongo</a></li>
                  </ul>
                  <h2 id="安装方法"><a href="#安装方法" class="headerlink" title="安装方法"></a>安装方法</h2>
                  <h3 id="pip-安装"><a href="#pip-安装" class="headerlink" title="pip 安装"></a>pip 安装</h3>
                  <p>推荐使用 pip3 安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> pymongo</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行完毕之后即可完成 PyMongo 的安装。</p>
                  <h2 id="验证安装"><a href="#验证安装" class="headerlink" title="验证安装"></a>验证安装</h2>
                  <p>为了验证库是否已经安装成功，可以在命令行下测试一下：</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span><span class="keyword">import</span> pymongo</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span>pymongo.version</span><br><span class="line"><span class="string">'3.11.2'</span></span><br><span class="line">&gt;&gt;&gt;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>在命令行首先输入 python3，进入命令行模式，输入如上内容，如果成功输出了其版本内容，那么证明 PyMongo 成功安装。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2021-10-03 03:39:41" itemprop="dateCreated datePublished" datetime="2021-10-03T03:39:41+08:00">2021-10-03</time>
                </span>
                <span id="/31040.html" class="post-meta-item leancloud_visitors" data-flag-title="PyMongo 的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>443</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <script>
              document.querySelectorAll('.random').forEach(item => item.src = "https://picsum.photos/id/" + Math.floor(Math.random() * Math.floor(300)) + "/200/133")

            </script>
            <nav class="pagination">
              <a class="extend prev" rel="prev" href="/page/2/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><a class="page-number" href="/page/2/">2</a><span class="page-number current">3</span><a class="page-number" href="/page/4/">4</a><span class="space">&hellip;</span><a class="page-number" href="/page/31/">31</a><a class="extend next" rel="next" href="/page/4/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
            </nav>
          </div>
          <script>
            window.addEventListener('tabs:register', () =>
            {
              let
              {
                activeClass
              } = CONFIG.comments;
              if (CONFIG.comments.storage)
              {
                activeClass = localStorage.getItem('comments_active') || activeClass;
              }
              if (activeClass)
              {
                let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
                if (activeTab)
                {
                  activeTab.click();
                }
              }
            });
            if (CONFIG.comments.storage)
            {
              window.addEventListener('tabs:click', event =>
              {
                if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
                let commentClass = event.target.classList[1];
                localStorage.setItem('comments_active', commentClass);
              });
            }

          </script>
        </div>
        <div class="toggle sidebar-toggle">
          <span class="toggle-line toggle-line-first"></span>
          <span class="toggle-line toggle-line-middle"></span>
          <span class="toggle-line toggle-line-last"></span>
        </div>
        <aside class="sidebar">
          <div class="sidebar-inner">
            <ul class="sidebar-nav motion-element">
              <li class="sidebar-nav-toc"> 文章目录 </li>
              <li class="sidebar-nav-overview"> 站点概览 </li>
            </ul>
            <!--noindex-->
            <div class="post-toc-wrap sidebar-panel">
            </div>
            <!--/noindex-->
            <div class="site-overview-wrap sidebar-panel">
              <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
                <img class="site-author-image" itemprop="image" alt="崔庆才" src="/images/avatar.png">
                <p class="site-author-name" itemprop="name">崔庆才</p>
                <div class="site-description" itemprop="description">崔庆才的个人站点，记录生活的瞬间，分享学习的心得。</div>
              </div>
              <div class="site-state-wrap motion-element">
                <nav class="site-state">
                  <div class="site-state-item site-state-posts">
                    <a href="/archives/">
                      <span class="site-state-item-count">608</span>
                      <span class="site-state-item-name">日志</span>
                    </a>
                  </div>
                  <div class="site-state-item site-state-categories">
                    <a href="/categories/">
                      <span class="site-state-item-count">24</span>
                      <span class="site-state-item-name">分类</span></a>
                  </div>
                  <div class="site-state-item site-state-tags">
                    <a href="/tags/">
                      <span class="site-state-item-count">156</span>
                      <span class="site-state-item-name">标签</span></a>
                  </div>
                </nav>
              </div>
              <div class="links-of-author motion-element">
                <span class="links-of-author-item">
                  <a href="https://github.com/Germey" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;Germey" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
                </span>
                <span class="links-of-author-item">
                  <a href="mailto:cqc@cuiqingcai.com.com" title="邮件 → mailto:cqc@cuiqingcai.com.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>邮件</a>
                </span>
                <span class="links-of-author-item">
                  <a href="https://weibo.com/cuiqingcai" title="微博 → https:&#x2F;&#x2F;weibo.com&#x2F;cuiqingcai" rel="noopener" target="_blank"><i class="fab fa-weibo fa-fw"></i>微博</a>
                </span>
                <span class="links-of-author-item">
                  <a href="https://www.zhihu.com/people/Germey" title="知乎 → https:&#x2F;&#x2F;www.zhihu.com&#x2F;people&#x2F;Germey" rel="noopener" target="_blank"><i class="fa fa-magic fa-fw"></i>知乎</a>
                </span>
              </div>
            </div>
            <div style=" width: 100%;" class="sidebar-panel sidebar-panel-image sidebar-panel-active">
              <a href="https://tutorial.lengyue.video/?coupon=12ef4b1a-a3db-11ea-bb37-0242ac130002_cqx_850" target="_blank" rel="noopener">
                <img src="https://qiniu.cuiqingcai.com/bco2a.png" style=" width: 100%;">
              </a>
            </div>
            <div style=" width: 100%;" class="sidebar-panel sidebar-panel-image sidebar-panel-active">
              <a href="http://www.ipidea.net/?utm-source=cqc&utm-keyword=?cqc" target="_blank" rel="noopener">
                <img src="https://qiniu.cuiqingcai.com/0ywun.png" style=" width: 100%;">
              </a>
            </div>
            <div class="sidebar-panel sidebar-panel-tags sidebar-panel-active">
              <h4 class="name"> 标签云 </h4>
              <div class="content">
                <a href="/tags/2048/" style="font-size: 10px;">2048</a> <a href="/tags/API/" style="font-size: 10px;">API</a> <a href="/tags/Bootstrap/" style="font-size: 11.25px;">Bootstrap</a> <a href="/tags/CDN/" style="font-size: 10px;">CDN</a> <a href="/tags/CQC/" style="font-size: 10px;">CQC</a> <a href="/tags/CSS/" style="font-size: 10px;">CSS</a> <a href="/tags/CSS-%E5%8F%8D%E7%88%AC%E8%99%AB/" style="font-size: 10px;">CSS 反爬虫</a> <a href="/tags/CV/" style="font-size: 10px;">CV</a> <a href="/tags/Django/" style="font-size: 10px;">Django</a> <a href="/tags/Eclipse/" style="font-size: 11.25px;">Eclipse</a> <a href="/tags/FTP/" style="font-size: 10px;">FTP</a> <a href="/tags/Git/" style="font-size: 10px;">Git</a> <a href="/tags/GitHub/" style="font-size: 13.75px;">GitHub</a> <a href="/tags/HTML5/" style="font-size: 10px;">HTML5</a> <a href="/tags/Hexo/" style="font-size: 10px;">Hexo</a> <a href="/tags/IT/" style="font-size: 10px;">IT</a> <a href="/tags/JSP/" style="font-size: 10px;">JSP</a> <a href="/tags/JavaScript/" style="font-size: 10px;">JavaScript</a> <a href="/tags/K8s/" style="font-size: 10px;">K8s</a> <a href="/tags/LOGO/" style="font-size: 10px;">LOGO</a> <a href="/tags/Linux/" style="font-size: 10px;">Linux</a> <a href="/tags/MIUI/" style="font-size: 10px;">MIUI</a> <a href="/tags/MongoDB/" style="font-size: 10px;">MongoDB</a> <a href="/tags/Mysql/" style="font-size: 10px;">Mysql</a> <a href="/tags/NBA/" style="font-size: 10px;">NBA</a> <a href="/tags/PHP/" style="font-size: 11.25px;">PHP</a> <a href="/tags/PS/" style="font-size: 10px;">PS</a> <a href="/tags/Pathlib/" style="font-size: 10px;">Pathlib</a> <a href="/tags/PhantomJS/" style="font-size: 10px;">PhantomJS</a> <a href="/tags/Python/" style="font-size: 15px;">Python</a> <a href="/tags/Python3/" style="font-size: 12.5px;">Python3</a> <a href="/tags/Pythonic/" style="font-size: 10px;">Pythonic</a> <a href="/tags/QQ/" style="font-size: 10px;">QQ</a> <a href="/tags/Redis/" style="font-size: 10px;">Redis</a> <a href="/tags/SAE/" style="font-size: 10px;">SAE</a> <a href="/tags/SSH/" style="font-size: 10px;">SSH</a> <a href="/tags/SVG/" style="font-size: 10px;">SVG</a> <a href="/tags/Scrapy/" style="font-size: 10px;">Scrapy</a> <a href="/tags/Scrapy-redis/" style="font-size: 10px;">Scrapy-redis</a> <a href="/tags/Scrapy%E5%88%86%E5%B8%83%E5%BC%8F/" style="font-size: 10px;">Scrapy分布式</a> <a href="/tags/Selenium/" style="font-size: 10px;">Selenium</a> <a href="/tags/TKE/" style="font-size: 10px;">TKE</a> <a href="/tags/Ubuntu/" style="font-size: 11.25px;">Ubuntu</a> <a href="/tags/VS-Code/" style="font-size: 10px;">VS Code</a> <a href="/tags/Vs-Code/" style="font-size: 10px;">Vs Code</a> <a href="/tags/Vue/" style="font-size: 11.25px;">Vue</a> <a href="/tags/Webpack/" style="font-size: 10px;">Webpack</a> <a href="/tags/Windows/" style="font-size: 10px;">Windows</a> <a href="/tags/Winpcap/" style="font-size: 10px;">Winpcap</a> <a href="/tags/WordPress/" style="font-size: 13.75px;">WordPress</a> <a href="/tags/Youtube/" style="font-size: 11.25px;">Youtube</a> <a href="/tags/android/" style="font-size: 10px;">android</a> <a href="/tags/ansible/" style="font-size: 10px;">ansible</a> <a href="/tags/cocos2d-x/" style="font-size: 10px;">cocos2d-x</a> <a href="/tags/e6/" style="font-size: 10px;">e6</a> <a href="/tags/fitvids/" style="font-size: 10px;">fitvids</a> <a href="/tags/git/" style="font-size: 11.25px;">git</a> <a href="/tags/json/" style="font-size: 10px;">json</a> <a href="/tags/js%E9%80%86%E5%90%91/" style="font-size: 10px;">js逆向</a> <a href="/tags/kubernetes/" style="font-size: 10px;">kubernetes</a> <a href="/tags/log/" style="font-size: 10px;">log</a> <a href="/tags/logging/" style="font-size: 10px;">logging</a> <a href="/tags/matlab/" style="font-size: 11.25px;">matlab</a> <a href="/tags/python/" style="font-size: 20px;">python</a> <a href="/tags/pytube/" style="font-size: 11.25px;">pytube</a> <a href="/tags/pywin32/" style="font-size: 10px;">pywin32</a> <a href="/tags/style/" style="font-size: 10px;">style</a> <a href="/tags/tomcat/" style="font-size: 10px;">tomcat</a> <a href="/tags/ubuntu/" style="font-size: 10px;">ubuntu</a> <a href="/tags/uwsgi/" style="font-size: 10px;">uwsgi</a> <a href="/tags/vsftpd/" style="font-size: 10px;">vsftpd</a> <a href="/tags/wamp/" style="font-size: 10px;">wamp</a> <a href="/tags/wineQQ/" style="font-size: 10px;">wineQQ</a> <a href="/tags/%E4%B8%83%E7%89%9B/" style="font-size: 11.25px;">七牛</a> <a href="/tags/%E4%B8%8A%E6%B5%B7/" style="font-size: 10px;">上海</a> <a href="/tags/%E4%B8%AA%E4%BA%BA%E7%BD%91%E7%AB%99/" style="font-size: 10px;">个人网站</a> <a href="/tags/%E4%B8%BB%E9%A2%98/" style="font-size: 10px;">主题</a> <a href="/tags/%E4%BA%91%E4%BA%A7%E5%93%81/" style="font-size: 10px;">云产品</a> <a href="/tags/%E4%BA%91%E5%AD%98%E5%82%A8/" style="font-size: 10px;">云存储</a> <a href="/tags/%E4%BA%AC%E4%B8%9C%E4%BA%91/" style="font-size: 10px;">京东云</a> <a href="/tags/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/" style="font-size: 12.5px;">人工智能</a> <a href="/tags/%E4%BB%A3%E7%90%86/" style="font-size: 10px;">代理</a> <a href="/tags/%E4%BB%A3%E7%A0%81/" style="font-size: 10px;">代码</a> <a href="/tags/%E4%BB%A3%E7%A0%81%E5%88%86%E4%BA%AB%E5%9B%BE/" style="font-size: 10px;">代码分享图</a> <a href="/tags/%E4%BC%98%E5%8C%96/" style="font-size: 10px;">优化</a> <a href="/tags/%E4%BD%8D%E8%BF%90%E7%AE%97/" style="font-size: 10px;">位运算</a> <a href="/tags/%E5%85%AC%E4%BC%97%E5%8F%B7/" style="font-size: 10px;">公众号</a> <a href="/tags/%E5%88%86%E4%BA%AB/" style="font-size: 10px;">分享</a> <a href="/tags/%E5%88%86%E5%B8%83%E5%BC%8F/" style="font-size: 10px;">分布式</a> <a href="/tags/%E5%88%9B%E4%B8%9A/" style="font-size: 10px;">创业</a> <a href="/tags/%E5%89%8D%E7%AB%AF/" style="font-size: 12.5px;">前端</a> <a href="/tags/%E5%8D%9A%E5%AE%A2/" style="font-size: 10px;">博客</a> <a href="/tags/%E5%8E%9F%E7%94%9FAPP/" style="font-size: 10px;">原生APP</a> <a href="/tags/%E5%8F%8D%E7%88%AC%E8%99%AB/" style="font-size: 12.5px;">反爬虫</a> <a href="/tags/%E5%91%BD%E4%BB%A4/" style="font-size: 10px;">命令</a> <a href="/tags/%E5%93%8D%E5%BA%94%E5%BC%8F%E5%B8%83%E5%B1%80/" style="font-size: 10px;">响应式布局</a> <a href="/tags/%E5%9E%83%E5%9C%BE%E9%82%AE%E4%BB%B6/" style="font-size: 10px;">垃圾邮件</a> <a href="/tags/%E5%9F%9F%E5%90%8D%E7%BB%91%E5%AE%9A/" style="font-size: 10px;">域名绑定</a> <a href="/tags/%E5%A4%8D%E7%9B%98/" style="font-size: 10px;">复盘</a> <a href="/tags/%E5%A4%A7%E4%BC%97%E7%82%B9%E8%AF%84/" style="font-size: 10px;">大众点评</a> <a href="/tags/%E5%AD%97%E4%BD%93%E5%8F%8D%E7%88%AC%E8%99%AB/" style="font-size: 10px;">字体反爬虫</a> <a href="/tags/%E5%AD%97%E7%AC%A6%E9%97%AE%E9%A2%98/" style="font-size: 10px;">字符问题</a> <a href="/tags/%E5%AD%A6%E4%B9%A0%E6%96%B9%E6%B3%95/" style="font-size: 10px;">学习方法</a> <a href="/tags/%E5%AE%89%E5%8D%93/" style="font-size: 10px;">安卓</a> <a href="/tags/%E5%AE%9E%E7%94%A8/" style="font-size: 10px;">实用</a> <a href="/tags/%E5%B0%81%E9%9D%A2/" style="font-size: 10px;">封面</a> <a href="/tags/%E5%B4%94%E5%BA%86%E6%89%8D/" style="font-size: 18.75px;">崔庆才</a> <a href="/tags/%E5%B7%A5%E5%85%B7/" style="font-size: 12.5px;">工具</a> <a href="/tags/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/" style="font-size: 10px;">开发工具</a> <a href="/tags/%E5%BE%AE%E8%BD%AF/" style="font-size: 10px;">微软</a> <a href="/tags/%E6%80%9D%E8%80%83/" style="font-size: 10px;">思考</a> <a href="/tags/%E6%89%8B%E6%9C%BA%E8%AE%BF%E9%97%AE/" style="font-size: 10px;">手机访问</a> <a href="/tags/%E6%95%99%E7%A8%8B/" style="font-size: 10px;">教程</a> <a href="/tags/%E6%95%99%E8%82%B2/" style="font-size: 10px;">教育</a> <a href="/tags/%E6%96%B0%E4%B9%A6/" style="font-size: 12.5px;">新书</a> <a href="/tags/%E6%96%B9%E6%B3%95%E8%AE%BA/" style="font-size: 10px;">方法论</a> <a href="/tags/%E6%97%85%E6%B8%B8/" style="font-size: 10px;">旅游</a> <a href="/tags/%E6%97%A5%E5%BF%97/" style="font-size: 10px;">日志</a> <a href="/tags/%E6%9A%97%E6%97%B6%E9%97%B4/" style="font-size: 10px;">暗时间</a> <a href="/tags/%E6%9D%9C%E5%85%B0%E7%89%B9/" style="font-size: 11.25px;">杜兰特</a> <a href="/tags/%E6%A1%8C%E9%9D%A2/" style="font-size: 10px;">桌面</a> <a href="/tags/%E6%AD%8C%E5%8D%95/" style="font-size: 10px;">歌单</a> <a href="/tags/%E6%B1%9F%E5%8D%97/" style="font-size: 10px;">江南</a> <a href="/tags/%E6%B8%B8%E6%88%8F/" style="font-size: 10px;">游戏</a> <a href="/tags/%E7%84%A6%E8%99%91/" style="font-size: 10px;">焦虑</a> <a href="/tags/%E7%88%AC%E8%99%AB/" style="font-size: 16.25px;">爬虫</a> <a href="/tags/%E7%88%AC%E8%99%AB%E4%B9%A6%E7%B1%8D/" style="font-size: 11.25px;">爬虫书籍</a> <a href="/tags/%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F/" style="font-size: 10px;">环境变量</a> <a href="/tags/%E7%94%9F%E6%B4%BB%E7%AC%94%E8%AE%B0/" style="font-size: 10px;">生活笔记</a> <a href="/tags/%E7%99%BB%E5%BD%95/" style="font-size: 10px;">登录</a> <a href="/tags/%E7%9F%A5%E4%B9%8E/" style="font-size: 10px;">知乎</a> <a href="/tags/%E7%9F%AD%E4%BF%A1/" style="font-size: 10px;">短信</a> <a href="/tags/%E7%9F%AD%E4%BF%A1%E9%AA%8C%E8%AF%81%E7%A0%81/" style="font-size: 10px;">短信验证码</a> <a href="/tags/%E7%AC%94%E8%AE%B0%E8%BD%AF%E4%BB%B6/" style="font-size: 10px;">笔记软件</a> <a href="/tags/%E7%AF%AE%E7%BD%91/" style="font-size: 10px;">篮网</a> <a href="/tags/%E7%BA%B8%E5%BC%A0/" style="font-size: 10px;">纸张</a> <a href="/tags/%E7%BB%84%E4%BB%B6/" style="font-size: 10px;">组件</a> <a href="/tags/%E7%BD%91%E7%AB%99/" style="font-size: 10px;">网站</a> <a href="/tags/%E7%BD%91%E7%BB%9C%E7%88%AC%E8%99%AB/" style="font-size: 11.25px;">网络爬虫</a> <a href="/tags/%E7%BE%8E%E5%AD%A6/" style="font-size: 10px;">美学</a> <a href="/tags/%E8%82%89%E5%A4%B9%E9%A6%8D/" style="font-size: 10px;">肉夹馍</a> <a href="/tags/%E8%85%BE%E8%AE%AF%E4%BA%91/" style="font-size: 10px;">腾讯云</a> <a href="/tags/%E8%87%AA%E5%BE%8B/" style="font-size: 10px;">自律</a> <a href="/tags/%E8%A5%BF%E5%B0%91%E7%88%B7/" style="font-size: 10px;">西少爷</a> <a href="/tags/%E8%A7%86%E9%A2%91/" style="font-size: 10px;">视频</a> <a href="/tags/%E8%B0%B7%E6%AD%8C%E9%AA%8C%E8%AF%81%E7%A0%81/" style="font-size: 10px;">谷歌验证码</a> <a href="/tags/%E8%BF%90%E8%90%A5/" style="font-size: 10px;">运营</a> <a href="/tags/%E8%BF%9C%E7%A8%8B/" style="font-size: 10px;">远程</a> <a href="/tags/%E9%80%86%E5%90%91/" style="font-size: 10px;">逆向</a> <a href="/tags/%E9%85%8D%E7%BD%AE/" style="font-size: 10px;">配置</a> <a href="/tags/%E9%87%8D%E8%A3%85/" style="font-size: 10px;">重装</a> <a href="/tags/%E9%98%BF%E6%9D%9C/" style="font-size: 10px;">阿杜</a> <a href="/tags/%E9%9D%99%E8%A7%85/" style="font-size: 17.5px;">静觅</a> <a href="/tags/%E9%A2%A0%E8%A6%86/" style="font-size: 10px;">颠覆</a> <a href="/tags/%E9%A3%9E%E4%BF%A1/" style="font-size: 10px;">飞信</a> <a href="/tags/%E9%B8%BF%E8%92%99/" style="font-size: 10px;">鸿蒙</a>
              </div>
              <script>
                const tagsColors = ['#00a67c', '#5cb85c', '#d9534f', '#567e95', '#b37333', '#f4843d', '#15a287']
                const tagsElements = document.querySelectorAll('.sidebar-panel-tags .content a')
                tagsElements.forEach((item) =>
                {
                  item.style.backgroundColor = tagsColors[Math.floor(Math.random() * tagsColors.length)]
                })

              </script>
            </div>
            <div class="sidebar-panel sidebar-panel-categories sidebar-panel-active">
              <h4 class="name"> 分类 </h4>
              <div class="content">
                <ul class="category-list">
                  <li class="category-list-item"><a class="category-list-link" href="/categories/C-C/">C/C++</a><span class="category-list-count">23</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/HTML/">HTML</a><span class="category-list-count">14</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Java/">Java</a><span class="category-list-count">5</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/JavaScript/">JavaScript</a><span class="category-list-count">26</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Linux/">Linux</a><span class="category-list-count">15</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Markdown/">Markdown</a><span class="category-list-count">1</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Net/">Net</a><span class="category-list-count">4</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Other/">Other</a><span class="category-list-count">39</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/PHP/">PHP</a><span class="category-list-count">27</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Paper/">Paper</a><span class="category-list-count">2</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Python/">Python</a><span class="category-list-count">261</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/TypeScript/">TypeScript</a><span class="category-list-count">2</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E4%B8%AA%E4%BA%BA%E5%B1%95%E7%A4%BA/">个人展示</a><span class="category-list-count">1</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E4%B8%AA%E4%BA%BA%E6%97%A5%E8%AE%B0/">个人日记</a><span class="category-list-count">9</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E4%B8%AA%E4%BA%BA%E8%AE%B0%E5%BD%95/">个人记录</a><span class="category-list-count">4</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E4%B8%AA%E4%BA%BA%E9%9A%8F%E7%AC%94/">个人随笔</a><span class="category-list-count">15</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/">安装配置</a><span class="category-list-count">59</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E6%8A%80%E6%9C%AF%E6%9D%82%E8%B0%88/">技术杂谈</a><span class="category-list-count">88</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E6%9C%AA%E5%88%86%E7%B1%BB/">未分类</a><span class="category-list-count">1</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E7%94%9F%E6%B4%BB%E7%AC%94%E8%AE%B0/">生活笔记</a><span class="category-list-count">1</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E7%A6%8F%E5%88%A9%E4%B8%93%E5%8C%BA/">福利专区</a><span class="category-list-count">6</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E8%81%8C%E4%BD%8D%E6%8E%A8%E8%8D%90/">职位推荐</a><span class="category-list-count">2</span></li>
                </ul>
              </div>
            </div>
            <div class="sidebar-panel sidebar-panel-friends sidebar-panel-active">
              <h4 class="name"> 友情链接 </h4>
              <ul class="friends">
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/j2dub.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.findhao.net/" target="_blank" rel="noopener">FindHao</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/ou6mm.jpg">
                  </span>
                  <span class="link">
                    <a href="https://diygod.me/" target="_blank" rel="noopener">DIYgod</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/6apxu.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.51dev.com/" target="_blank" rel="noopener">IT技术社区</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://www.jankl.com/img/titleshu.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.jankl.com/" target="_blank" rel="noopener">liberalist</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/bqlbs.png">
                  </span>
                  <span class="link">
                    <a href="http://www.urselect.com/" target="_blank" rel="noopener">优社电商</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/8s88c.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.yuanrenxue.com/" target="_blank" rel="noopener">猿人学</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/2wgg5.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.yunlifang.cn/" target="_blank" rel="noopener">云立方</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/shwr6.png">
                  </span>
                  <span class="link">
                    <a href="http://lanbing510.info/" target="_blank" rel="noopener">冰蓝</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/blvoh.jpg">
                  </span>
                  <span class="link">
                    <a href="https://lengyue.me/" target="_blank" rel="noopener">冷月</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="http://qianxunclub.com/favicon.png">
                  </span>
                  <span class="link">
                    <a href="http://qianxunclub.com/" target="_blank" rel="noopener">千寻啊千寻</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/0044u.jpg">
                  </span>
                  <span class="link">
                    <a href="http://kodcloud.com/" target="_blank" rel="noopener">可道云</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/ygnpn.jpg">
                  </span>
                  <span class="link">
                    <a href="http://www.kunkundashen.cn/" target="_blank" rel="noopener">坤坤大神</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/22uv1.png">
                  </span>
                  <span class="link">
                    <a href="http://www.cenchong.com/" target="_blank" rel="noopener">岑冲博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/ev9kl.png">
                  </span>
                  <span class="link">
                    <a href="http://www.zxiaoji.com/" target="_blank" rel="noopener">张小鸡</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://www.503error.com/favicon.ico">
                  </span>
                  <span class="link">
                    <a href="https://www.503error.com/" target="_blank" rel="noopener">张志明个人博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/x714o.jpg">
                  </span>
                  <span class="link">
                    <a href="http://www.hubwiz.com/" target="_blank" rel="noopener">汇智网</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/129d8.png">
                  </span>
                  <span class="link">
                    <a href="https://www.bysocket.com/" target="_blank" rel="noopener">泥瓦匠BYSocket</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://www.xiongge.club/favicon.ico">
                  </span>
                  <span class="link">
                    <a href="https://www.xiongge.club/" target="_blank" rel="noopener">熊哥club</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/3w4fe.png">
                  </span>
                  <span class="link">
                    <a href="https://zerlong.com/" target="_blank" rel="noopener">知语</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/44hxf.png">
                  </span>
                  <span class="link">
                    <a href="http://redstonewill.com/" target="_blank" rel="noopener">红色石头</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/8g1fk.jpg">
                  </span>
                  <span class="link">
                    <a href="http://www.laodong.me/" target="_blank" rel="noopener">老董博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/wkaus.jpg">
                  </span>
                  <span class="link">
                    <a href="https://zhaoshuai.me/" target="_blank" rel="noopener">碎念</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/pgo0r.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.chenwenguan.com/" target="_blank" rel="noopener">陈文管的博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/kk82a.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.lxlinux.net/" target="_blank" rel="noopener">良许Linux教程网</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/lj0t2.jpg">
                  </span>
                  <span class="link">
                    <a href="https://tanqingbo.cn/" target="_blank" rel="noopener">IT码农</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/i8cdr.png">
                  </span>
                  <span class="link">
                    <a href="https://junyiseo.com/" target="_blank" rel="noopener">均益个人博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/chwv2.png">
                  </span>
                  <span class="link">
                    <a href="https://brucedone.com/" target="_blank" rel="noopener">大鱼的鱼塘</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/2y43o.png">
                  </span>
                  <span class="link">
                    <a href="http://bbs.nightteam.cn/" target="_blank" rel="noopener">夜幕爬虫安全论坛</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/zvc3w.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.weishidong.com/" target="_blank" rel="noopener">韦世东的技术专栏</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/ebudy.jpg">
                  </span>
                  <span class="link">
                    <a href="https://chuanjiabing.com/" target="_blank" rel="noopener">穿甲兵技术社区</a>
                  </span>
                </li>
              </ul>
            </div>
          </div>
        </aside>
        <div id="sidebar-dimmer"></div>
      </div>
    </main>
    <footer class="footer">
      <div class="footer-inner">
        <div class="copyright"> &copy; <span itemprop="copyrightYear">2021</span>
          <span class="with-love">
            <i class="fa fa-heart"></i>
          </span>
          <span class="author" itemprop="copyrightHolder">崔庆才丨静觅</span>
          <span class="post-meta-divider">|</span>
          <span class="post-meta-item-icon">
            <i class="fa fa-chart-area"></i>
          </span>
          <span title="站点总字数">2.6m</span>
          <span class="post-meta-divider">|</span>
          <span class="post-meta-item-icon">
            <i class="fa fa-coffee"></i>
          </span>
          <span title="站点阅读时长">39:54</span>
        </div>
        <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动 </div>
        <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">京ICP备18015597号-1 </a>
        </div>
        <script>
          (function ()
          {
            function leancloudSelector(url)
            {
              url = encodeURI(url);
              return document.getElementById(url).querySelector('.leancloud-visitors-count');
            }

            function addCount(Counter)
            {
              var visitors = document.querySelector('.leancloud_visitors');
              var url = decodeURI(visitors.id);
              var title = visitors.dataset.flagTitle;
              Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify(
              {
                url
              }))).then(response => response.json()).then((
              {
                results
              }) =>
              {
                if (results.length > 0)
                {
                  var counter = results[0];
                  leancloudSelector(url).innerText = counter.time + 1;
                  Counter('put', '/classes/Counter/' + counter.objectId,
                  {
                    time:
                    {
                      '__op': 'Increment',
                      'amount': 1
                    }
                  }).catch(error =>
                  {
                    console.error('Failed to save visitor count', error);
                  });
                }
                else
                {
                  Counter('post', '/classes/Counter',
                  {
                    title,
                    url,
                    time: 1
                  }).then(response => response.json()).then(() =>
                  {
                    leancloudSelector(url).innerText = 1;
                  }).catch(error =>
                  {
                    console.error('Failed to create', error);
                  });
                }
              }).catch(error =>
              {
                console.error('LeanCloud Counter Error', error);
              });
            }

            function showTime(Counter)
            {
              var visitors = document.querySelectorAll('.leancloud_visitors');
              var entries = [...visitors].map(element =>
              {
                return decodeURI(element.id);
              });
              Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify(
              {
                url:
                {
                  '$in': entries
                }
              }))).then(response => response.json()).then((
              {
                results
              }) =>
              {
                for (let url of entries)
                {
                  let target = results.find(item => item.url === url);
                  leancloudSelector(url).innerText = target ? target.time : 0;
                }
              }).catch(error =>
              {
                console.error('LeanCloud Counter Error', error);
              });
            }
            let
            {
              app_id,
              app_key,
              server_url
            } = {
              "enable": true,
              "app_id": "6X5dRQ0pnPWJgYy8SXOg0uID-gzGzoHsz",
              "app_key": "ziLDVEy73ne5HtFTiGstzHMS",
              "server_url": "https://6x5drq0p.lc-cn-n1-shared.com",
              "security": false
            };

            function fetchData(api_server)
            {
              var Counter = (method, url, data) =>
              {
                return fetch(`${api_server}/1.1${url}`,
                {
                  method,
                  headers:
                  {
                    'X-LC-Id': app_id,
                    'X-LC-Key': app_key,
                    'Content-Type': 'application/json',
                  },
                  body: JSON.stringify(data)
                });
              };
              if (CONFIG.page.isPost)
              {
                if (CONFIG.hostname !== location.hostname) return;
                addCount(Counter);
              }
              else if (document.querySelectorAll('.post-title-link').length >= 1)
              {
                showTime(Counter);
              }
            }
            let api_server = app_id.slice(-9) !== '-MdYXbMMI' ? server_url : `https://${app_id.slice(0, 8).toLowerCase()}.api.lncldglobal.com`;
            if (api_server)
            {
              fetchData(api_server);
            }
            else
            {
              fetch('https://app-router.leancloud.cn/2/route?appId=' + app_id).then(response => response.json()).then((
              {
                api_server
              }) =>
              {
                fetchData('https://' + api_server);
              });
            }
          })();

        </script>
      </div>
      <div class="footer-stat">
        <span id="cnzz_stat_icon_1279355174"></span>
        <script type="text/javascript">
          document.write(unescape("%3Cspan id='cnzz_stat_icon_1279355174'%3E%3C/span%3E%3Cscript src='https://v1.cnzz.com/z_stat.php%3Fid%3D1279355174%26online%3D1%26show%3Dline' type='text/javascript'%3E%3C/script%3E"));

        </script>
      </div>
    </footer>
  </div>
  <script src="//cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js"></script>
  <script src="/js/utils.js"></script>
  <script src="/.js"></script>
  <script src="/js/schemes/pisces.js"></script>
  <script src="/.js"></script>
  <script src="/js/next-boot.js"></script>
  <script src="/.js"></script>
  <script>
    (function ()
    {
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x = document.getElementsByTagName("link");
      //Find the last canonical URL
      if (x.length > 0)
      {
        for (i = 0; i < x.length; i++)
        {
          if (x[i].rel.toLowerCase() == 'canonical' && x[i].href)
          {
            canonicalURL = x[i].href;
          }
        }
      }
      //Get protocol
      if (!canonicalURL)
      {
        curProtocol = window.location.protocol.split(':')[0];
      }
      else
      {
        curProtocol = canonicalURL.split(':')[0];
      }
      //Get current URL if the canonical URL does not exist
      if (!canonicalURL) canonicalURL = window.location.href;
      //Assign script content. Replace current URL with the canonical URL
      ! function ()
      {
        var e = /([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,
          r = canonicalURL,
          t = document.referrer;
        if (!e.test(r))
        {
          var n = (String(curProtocol).toLowerCase() === 'https') ? "https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif" : "//api.share.baidu.com/s.gif";
          t ? (n += "?r=" + encodeURIComponent(document.referrer), r && (n += "&l=" + r)) : r && (n += "?l=" + r);
          var i = new Image;
          i.src = n
        }
      }(window);
    })();

  </script>
  <script src="/js/local-search.js"></script>
  <script src="/.js"></script>
</body>

</html>
